从github下载的vue项目启动宝Cannot Get错误,网上参考出现该错误来源很多,这里先总结遇到的第一个解决方法。
参考地址:
https://www.cnblogs.com/anns/p/7457952.html
代码修改如下:
在config-》index.js中修改 assetsPublicPath: ‘/‘, 为 assetsPublicPath: ‘./‘, 再执行 npm run dev ,问题解决
build: { env: require(‘./prod.env‘), index: path.resolve(__dirname, ‘../dist/modules/index/index.html‘), phone: path.resolve(__dirname, ‘../dist/modules/phone/phone.html‘), assetsRoot: path.resolve(__dirname, ‘../dist‘), assetsSubDirectory: ‘static‘, assetsPublicPath: ‘./‘, productionSourceMap: true, // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. // Before setting to `true`, make sure to: // npm install --save-dev compression-webpack-plugin productionGzip: false, productionGzipExtensions: [‘js‘, ‘css‘], bundleAnalyzerReport: process.env.npm_config_report },
注意,不能更改dev下的代码。
附上下来项目的来源:
https://github.com/chen1218chen/vue-cli-multi-page
原文地址:https://www.cnblogs.com/yyk1226/p/9413254.html
时间: 2024-10-29 14:16:18