Config
coderljw 2024-10-13 小于 1 分钟
# 1. 环境配置
App.vue
import '.env.js' export default { globalData: UNI_ENV, }
1
2
3
4
5env.js
;(function () { UNI_ENV = process.env.NODE_ENV === 'development' ? require('.env.dev.js') : require('.env.prod.js') })()
1
2
3
4
5
6env.dev.js
为了调试方便使用浏览器预览,在 manifest.json 配置代理。
const UNI_ENV = { BASE_API: '/agency', COINDOG_API: '/coindog-agency', } module.exports = UNI_ENV
1
2
3
4
5
6env.prod.js
const UNI_ENV = { BASE_API: 'https://www.coderljw.ga', COINDOG_API: 'http://api.coindog.com', } module.exports = UNI_ENV
1
2
3
4
5
6
# 2. manifest.json
{
"h5": {
"devServer": {
"port": 9000,
// 开发App/H5浏览器预览
"proxy": {
"/agency": {
"target": "http://www.coderljw.ga:4396",
"changeOrigin": true,
"pathRewrite": {
"^/agency": ""
}
},
"/coindog-agency": {
"target": "http://api.coindog.com/topic/list",
"changeOrigin": true,
"pathRewrite": {
"^/coindog-agency": ""
}
}
}
}
},
"app-plus": {
// App去除开屏雪花加载
"splashscreen": {
"alwaysShowBeforeRender": false,
"waiting": false,
"autoclose": true,
"delay": 0
}
}
}
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
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
# 3. pages.json
{
"globalStyle": {
"navigationStyle": "custom",
"backgroundColor": "#040404",
// App全局配置
"app-plus": {
"titleNView": false,
"bounce": "none",
"background": "#040404",
"animationAlphaBGColor": "#040404",
"animationType": "slide-in-right"
}
},
// easycom模式使用组件
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue",
"^c-(.*)": "@/components/c-$1.vue"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19