报的错:
Uncaught SyntaxError: Unexpected token '<' (at chunk-vendors.5ea7a1b2.js:1:1)
Uncaught SyntaxError: Unexpected token '<' (at app.5e29bd6c.js:1:1)
Vue 项目,用vue-cli打包上线后,播以上错误,
打开打包后的index.html文件看。发现是路径问题,所有的文件都没有引入的index.html中
解决办法:
在vue.config.js中 (如果没有这个文件,自己创建一个)
然后写入以下代码:
module.exports = {
// 打包文件访问的相对目录 独立项目 通过项目根目录访问
// publicPath: './', // http://localhost:5000
// 打包到子域下面 http://www.baidu.com/map
publicPath: './'
}
到这里还没有解决的话,
再在jsconfig.js (没有创建) 写入如下代码:
{
"compilerOptions": {
"baseUrl": "./"
},
"exclude": [
"node_modules"
]
}