一、 Vue-cli创建项打包后打开页面为空白的问题解决 命令行输入:npm run build 打包出来后项目中就会多了一个文件夹dist,这就是我们打包过后的项目。 二、打包完
命令行输入:npm run build
打包出来后项目中就会多了一个文件夹dist,这就是我们打包过后的项目。
配置如下:
const path = require("path");
const resolve = function(dir) {
return path.join(__dirname, dir);
};
module.exports = {
publicPath: process.env.node_ENV === "production" ? "./" : "./",
outputDir: "dist",
assetsDir: "static",
lintOnSave: true, // 是否开启eslint保存检测
productionSourceMap: false, // 是否在构建生产包时生成sourcdeMap
chainwebpack: config => {
config.resolve.alias
.set("@", resolve("src"))
.set("@v", resolve("src/views"))
.set("@c", resolve("src/components"))
.set("@u", resolve("src/utils"))
.set("@s", resolve("src/service"));
config.optimization.runtimeChunk("single");
},
devServer: {
// host: "localhost",
//host: "192.168.1.107",
host: "0.0.0.0", //局域网和本地访问
port: "8080",
hot: true,
open: false,
overlay: {
warning: false,
error: true
},
proxy: {
"/api": {
target: "Http://m260048y71.zicp.vip", //
// target: "http://192.168.1.102:8888", //
changeOrigin: true,
ws: true,
pathRewrite: {
"^/api": ""
}
}
}
}
};
这个坑是当你使用了路由之后,在没有后端配合的情况下就手贱打开路由history模式的时候,打包出来的文件也会是一片空白的情况,
解决:在 router.js 中将 mode: history注释掉
到此这篇关于Vue打包后页面出现空白解决办法的文章就介绍到这了,更多相关Vue打包页面出现空白内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: Vue打包后页面出现空白解决办法
本文链接: https://www.lsjlt.com/news/131760.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0