router在history模式下,二级路由的path命名问题。
原本的path:
path: '/products/new-products'
更改后的path:
path: '/new-products'
原因:
1.查询资料后发现,注释掉vue.config.js中的publicPath可以解决问题,但新的问题出现了。
图片获取不到,在F12的网络中检查请求路径时发现图片的地址被改变。
原本是:localhost:8080/img/1.jpg
变成了:localhost:8080/products/img/1.jpg
因此猜测是路径问题。
2.尝试将二级路由去掉前缀/products/,图片请求成功,地址变回localhost:8080/img/1.jpg
所以和vue.config.js中的publicPath因该没太大关系,主要是路由模式的命名问题。
在history模式下应该保证路径只有一层,即只有一个'/'符号。
- SyntaxError Unexpected Uncaught 情况 tokensyntaxerror unexpected uncaught情况 syntaxerror unexpected uncaught页面 syntaxerror unexpected uncaught invalid syntaxerror unexpected jconstant uncaught syntaxerror unexpected token vite tagoffsetsmap syntaxerror unexpected token originalprompt syntaxerror identifier uncaught codepoint syntaxerror unexpected amp my_customer_index syntaxerror unexpected identifier syntaxerror staticrende unexpected expected