当前位置: 移动技术网 > IT编程>脚本编程>vue.js > 解决vue-cli3 使用子目录部署问题

解决vue-cli3 使用子目录部署问题

2018年08月06日  | 移动技术网IT编程  | 我要评论

yy2013年度盛典排名,金乡生活网,风野七咒txt下载

在使用 vue-cli3 build的时候,使用非子目录需要在 vue.config.js 中添加如下代码:

module.exports = {
 baseurl: process.env.node_env === 'production' ? '/dist/' : '/',
}

但是build完后,放在nginx服务下,会看到如下报错,页面也显示 no-script 的内容

[vue warn]: you are using the runtime-only build of vue where the template compiler is not available. either pre-compile the templates into render functions, or use the compiler-included build.

网上找了很多,并没有找到答案。后来发现 vue-router 是用了 history 模式,但是 nginx 并没有添加相应的配置便会出现这个问题。所以,如下解决方案:

1.变更生产环境配置,使得支持 history 模式。这里只需要修改 nginx 的配置,把 404 指向 即可。
2.不在使用history模式

总结

以上所述是小编给大家介绍的vue-cli3 使用子目录部署问题,希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网