错误一:文件丢失
Failed to load resource: net::ERR_FILE_NOT_FOUND app.16a9ce322fd2576ad4dc0c4e2f179340.css
Failed to load resource: net::ERR_FILE_NOT_FOUND manifest.2ae2e69a05c33dfc65f8.js
Failed to load resource: net::ERR_FILE_NOT_FOUND vendor.52cdff1b8b2713aa5b5c.js
Failed to load resource: net::ERR_FILE_NOT_FOUND app.0682779b98685cbabc81.js
方案:修改config文件夹下的index.js文件
//原文件
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/'
//...下面代码省略
}
//修改后
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './' //主要修改这里
//...下面代码省略
}
错误二:图片丢失
方案:修改build.js中的utils.js文件
//原文件
function generateLoaders (loader, loaderOptions) {
//...以上代码省略
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
//修改后
function generateLoaders (loader, loaderOptions) {
//...以上代码省略
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
publicPath:'../../', //主要修改这里
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}