宁波搭建网站公,为什么要建设档案网站,哪个网站是专门做兼职的,网站备案准备资料临时纯手工搭建开发了个vue2小项目#xff0c;打包后出现了很多问题
一、打包后index.html打开空白
打包后整个页面空白#xff0c;是因为打包后资源路径不对#xff0c;需要修改config-index.js下#xff0c;build属性中assetsPublicPath值为./
module.exports {d…临时纯手工搭建开发了个vue2小项目打包后出现了很多问题
一、打包后index.html打开空白
打包后整个页面空白是因为打包后资源路径不对需要修改config-index.js下build属性中assetsPublicPath值为./
module.exports {dev:{...},build:{...assetsPublicPath: ./,//默认是/需要改为./...}
}二、打包后图片等静态资源无法显示
需要修改build下utils.js文件新增一句话大致位置如下重点看注释处提示
...
exports.cssLoaders function (options) {...function generateLoaders (loader, loaderOptions) {// Extract CSS when that option is specified// (which is the case during production build)if (options.extract) {return ExtractTextPlugin.extract({use: loaders,fallback: vue-style-loader,publicPath:../../ //新增的部分})} else {return [vue-style-loader].concat(loaders)}
}三、打包后凡是router-view的地方都没有加载
打开dist中html文件打开控制台检查会发现该显示router-view的地方没有元素只有一个空注释!---- 需要修改router的默认mode值默认为hsiotry改成hash模式
import Vue from vue;
import VueRouter from vue-router;Vue.use(VueRouter)const routes [...
]
const router new VueRouter({routes,mode:hash //框架默认生成时这里是值为hsitory
})export default router