1、项目上线之后,报错dayjs is not a function;
import * as dayjs from "dayjs"; //这里报错 不需要这样引入 直接引入下面这条即可解决
import dayjs from "dayjs";
2、项目上线报错:Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “text/html”. Strict MIME type checking is enforced for module scripts per HTML spec.
a、如果使用得是nginx发布,则需要配置
location /文件夹名称 {
alias html/文件夹名称/;
index index.html index.htm;
add_header 'Access-Control-Allow-Origin' '*';
try_files $uri $uri/ /index.html;
}
b、需要设置vite.config.ts
base:'./',
3、项目上线之后:报错We‘re sorry but doesn‘t work properly without JavaScript enabled. Please enable it to continue。
项目使用得是axios,参考其他资料,重启服务器,问题未解决。使用的是GET请求,输出结果中,Content-Type为 text/html。修改axios的Content-Type无效,貌似修改Content-Type 只对POST请求有效,后将请求改为POST请求之后,获取到正确结果。
4、项目在本地运行正常,上线之后报错 Unexpected token ‘<’, ")
原因:静态文件引入错误,原来的静态文件在src/testData,将文件放到public.
将url: ‘src/testData/********.json’ 改为 url: ‘./testData/*******.json’。