Vue项目打包问题

513 阅读1分钟

vue项目打包上线时报错‘Failed to load resource: net::ERR_FILE_NOT_FOUND‘

  • 问题描述
    vue项目打包上线时报错’Failed to load resource: net::ERR_FILE_NOT_FOUND’,如下图所示: image.png 原因分析及解决方案:
    这里的确是css以及js文件的路径问题,但解决时并不需要手动改路径或者加一段判断去修改,最方便的办法时在项目打包前的vue.config.js里面将publicPath属性添加或者修改为 publicPath: ‘./’, 然后重新打包。
    修改为:
const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({

  transpileDependencies: true,

  publicPath: './'

})

[vue打包后出现"Failed to load resource: net::ERR_FILE_NOT_FOUND"错误 - 护花使者 - 博客园](www.cnblogs.com/chenmz1995/… "vue打包后出现"Failed to load resource: net::ERR_FILE_NOT_FOUND"错误 - 护花使者 - 博客园")