当前位置:首页 > 编程笔记 > 正文
已解决

浏览器控制台报错Failed to load module script:解决方法

来自网友在路上 196896提问 提问时间:2023-11-08 09:47:24阅读次数: 96

最佳答案 问答题库968位专家为你答疑解惑

浏览器控制台报错Failed to load module script:解决方法

在vue项目打包上传至服务器出现的报错。因为nginx转发路径问题,记录一下:
原本nginx直指向了一个前端项目,后来又加了一个,就直接复制的上一次的,导致变量名重复报的错

// 原来错误的代码,@router 变量名错误
location ^~/visitor/ {try_files $uri $uri/ @router;alias  /nsfocus/local/nginx/html/visitor/;index index.html;
}
location @router{rewrite ^.*$ /visitor/index.html last;
}location ^~/seats/ {try_files $uri $uri/ @router;alias  /nsfocus/local/nginx/html/seats/;index index.html;
}
location @router{rewrite ^.*$ /seats/index.html last;
}
-----------------------------------------------------------------------------
// 正确配置,应该区分开来
location ^~/visitor/ {try_files $uri $uri/ @visitor_router;alias  /nsfocus/local/nginx/html/visitor/;index index.html;
}
location @visitor_router{rewrite ^.*$ /visitor/index.html last;
}location ^~/seats/ {try_files $uri $uri/ @seats_router;alias  /nsfocus/local/nginx/html/seats/;index index.html;
}
location @seats_router{rewrite ^.*$ /seats/index.html last;
}
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"浏览器控制台报错Failed to load module script:解决方法":http://eshow365.cn/6-35244-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!