• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
时光里的赶路人
博客园    首页    新随笔    联系   管理    订阅  订阅
HBuilder打包vue2.0项目生成的APK空白(已解决)

1、config下面的index.js中bulid模块导出的路径,因为index.html里边的内容都是通过script标签引入的,而路径不对,打开肯定是空白的。先看一下默认的路径。

  build: {
    // Template for index.html
    // Paths  需要修改的是这里的路径
    index: path.resolve(__dirname, '../dist/index.html'),// Paths  需要修改的是这里的路径
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',


    /**
     * Source Maps
     */

    productionSourceMap: false,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: 'none',
    // devtool: '#source-map',
 
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
 
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }

 assetsPublicPath默认的是 ‘/’ 也就是根目录。而我们的index.html和static在同一级目录下面。 所以要改为 ‘./ ’。

2.第二个需要改的是router下的index.js, mode:'history’里的history改成hash。

  mode:'history’打包的apk,打开之后页面是空白的,我找了好几天才找到原因。

posted on 2023-09-19 18:02  吹风哪页就哪页  阅读(1103)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3