加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 02:16:35 所属栏目:百科 来源:网络整理
导读:在使用 vue-cli3 build的时候,使用非子目录需要在 vue.config.js 中添加如下代码: 但是build完后,放在nginx服务下,会看到如下报错,页面也显示 no-script 的内容 [Vue warn]: You are using the runtime-only build of Vue where the template compiler

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

但是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 指向 index.html 即可。 2.不在使用history模式

总结

以上所述是小编给大家介绍的vue-cli3 使用子目录部署问题。编程之家 52php.cn 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读