vue项目 build之后资源文件找不到问题

解决静态资源失效的问题

这就需要修改我们的 config 中的 index.js了,默认的build 中的部分是这样的:

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: './',

但是这样能确保资源文件可被正常找到, 但页面还是处于白屏状态,

在路由页面找到mode: 'history',

export default new Router({
mode: 'history',
routes: [

mode: 'history',这句话删除,在进行build,

export default new Router({
// mode: 'history',
routes: [

小伙伴们, 是不是发现好用啦

你可能感兴趣的:(Vue)