"Failed to load resource: net::ERR_FILE_NOT_FOUND"错误 。vue-cli 3.0 创建的项目,dev下能运行,打包后报错,页面空白 。

cli3.0  解决办法:

 Failed to load resource: net::ERR_FILE_NOT_FOUND

 

打开dist/index.html, 引入是有问题的,

 

在vue-cli 3.0 创建的项目中是找不到webpack的配置文件,因为vue-cli 3.0 将其封装起来了,只需要在项目的根目录下的vue.config.js文件中修改就行了(若项目没有该文件,直接在根目录下添加一个),将baseUrl的值设为 ‘./’即可,修改如下

const webpack = require("webpack");
module.exports = {
    pluginOptions: new webpack.ProvidePlugin({
        jQuery: "jquery",
        $: "jquery"
    }),
    baseUrl: './' // 加入这行就可以了
};

 

cli2.x  解决办法:

打开config/index.js文件,将build->assetsPublicPath改为“./”,即可,就是前面加个点。

build: {
  // Template for index.html
  index: path.resolve(__dirname, '../dist/index.html'),

  // Paths
  assetsRoot: path.resolve(__dirname, '../dist'),
  assetsSubDirectory: 'static',
  assetsPublicPath: './',  // 修改这里的代码

}

好了 2.x  3.0 都可以解决了

转载请注明出处

 

你可能感兴趣的:(npm,vue,js)