文章已阅读
 

打包后由于路径不对,导致资源文件加载不到,需要调整:

1.config/index.js 修改以下两个地方

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
1).

module.exports = {

dev:{

// Paths

assetsSubDirectory: 'static',

// assetsPublicPath: '/',/*调试*/

assetsPublicPath: './',/*发布*/

proxyTable: {

changeOrigin: true,/*允许跨域*/

\"/api\": {

target:\"https://www.romanticlife.top\",

// target:\"http://localhost:8090\",

secure:false,

changeOrigin: true,

pathRewrite: {

'^/api': ''

}

},

},


2).


build: {

// Template for index.html

index: path.resolve(__dirname, '../dist/index.html'),


// Paths

assetsRoot: path.resolve(__dirname, '../dist'),

assetsSubDirectory: 'static',

// assetsPublicPath: '/',/*调试*/

assetsPublicPath: './',/*发布*/

一般来说第一步就能解决问题,如果还不行就继续以下步骤:

1
2
3
4
5
2.build/webpack.prod.conf.js
在output中添加publicPath:'./',

3.build/utils.js
51行---修改为 publicPath:'../../'
2022-10-08

浏览 |

© 2023 南疆 with help from Hexo and Twitter Bootstrap. Theme by Freemind.

container-narrow -->