相信有不少同窗在學習vue的剛開始都遇到過項目打包發佈後發現CSS中的背景圖片不顯示,具體如何解決只須要更改bind的配置便可css
修改 build/utils.js 中的 generateLoaders 方法,以下代碼,增長 publicPath: '…/…/'vue
// generate loader string to be used with extract text plugin function generateLoaders (loader, loaderOptions) { const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] if (loader) { loaders.push({ loader: loader + '-loader', options: Object.assign({}, loaderOptions, { sourceMap: options.sourceMap }) }) } // Extract CSS when that option is specified // (which is the case during production build) if (options.extract) { return ExtractTextPlugin.extract({ use: loaders, publicPath: '../../', fallback: 'vue-style-loader' }) } else { return ['vue-style-loader'].concat(loaders) } }