处理 vue history模式打包后页面为空白页的问题

Admin 2020-04-22 PM 11350℃ 4条

场景如下:

微信或者第三方登录回调地址,有#号时,接收不到code参数,或者处理起来非常复杂
微信H5支付的回调地址,不允许有#
App分享,处理特殊字符时,可能会对#进行编译
开发App嵌入式页面时,与框架字段兼容性取值异常

解决步骤:

  1. 在vue根目录下创建vue.config.js 文件,内容如下
// product为工程名
module.exports = {
    publicPath: '/product/',
    outputDir: 'product'
}
  1. 修改router.js 文件
// product为工程名
const router = new VueRouter({
  mode: 'history',
  base: '/product/',
  routes
})
  1. 联合后端同事,修改Nginx配置
// product为工程名
location /product {
    index  index.html index.htm;
    try_files $uri $uri/ /product /;
}
标签: none

非特殊说明,本博所有文章均为博主原创。

评论啦~


选择表情

已有 4 条评论


  1. 处理 vue history模式打包后页面为空白页的问题 R11; 有爱前端

    [...]https://www.qzroc.com/index.php/archives/78/[...]

    回复 2020-04-27 08:19
  2. 赵铁柱
    赵铁柱

    大哥我已经发了邮件问你了,你不说有回嘛?等了几天都没回我

    回复 2020-04-24 17:01
    1. Admin
      Admin 博主

      icon_lol.png 已回复

      回复 2020-04-28 09:58