vue项目打包完成后,打开index.html会出现空白页,有两个原因
1. publicPath配置应该是相对路径“./”,不能是“/”
module.exports = {
publicPath:"./",
//这里是配置的开发过程中解决跨域问题
devServer: {
open: true,
host: 'localhost',
port: 8080,
https:false,
proxy: {
'/api': {
//target里是我们需要访问的接口的域名
target: 'https://api.seanai.cn/wise/1',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/api': '/' //请求的时候使用api去拼接剩下的具体请求的url即可
}
},
}
}
}
2.因为router中配置的是history路由,也就是mode:history,注释掉就可以了
const router = new VueRouter({
// mode: 'history',
base: process.env.BASE_URL,
routes
})