部署前端项目报错Uncaught SyntaxError: Unexpected token
1.产生原因:前端使用了BrowserRouter路由方式,当跳转二级路由时,前端所引用的js文件以及css 文件路径会因二级路由的原因所改变。
2.解决:配置webpack,
output:{
...,
publicPath:isEnvProduction?'/':'.'
}
当前端使用BrowserRouter时,刷新页面会出现404.
解决:
nginx —:配置
location / {
root /var/www/html;
index index.html index.html;
try_files $uri /index.html;
}