Skip to content

Commit a432eda

Browse files
committed
init
1 parent 218d429 commit a432eda

File tree

6 files changed

+69
-64
lines changed

6 files changed

+69
-64
lines changed

README copy.md

-60
This file was deleted.

README.md

+54-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,46 @@
1111

1212
## 简介
1313

14+
> 本模板非集成方案, 只是做底层的一套基本配置,包括以下内容
15+
16+
```
17+
1. 路由
18+
2. axios 封装(请求拦截, 响应拦截, 页面切换取消ajax请求),请求加载loading
19+
3. 移动端适配
20+
4. px 自动转 rem
21+
5. svg渲染组件
22+
6. 页面渲染前空白处理
23+
7. 服务器接口环境配置
24+
8. 路由切换动画(闪屏问题处理)
1425
```
15-
- 登录 / 注销
1626

27+
## 目录
28+
29+
```bash
30+
├── package.json
31+
├── public
32+
│ ├── favicon.ico
33+
│ └── index.html
34+
├── src
35+
│ ├── assets 静态资源
36+
│ ├── components 组件
37+
│ ├── icons svg图标
38+
│ ├── plugins vant按需加载的组件
39+
│ ├── router 路由
40+
│ ├── service 接口
41+
│ ├── store vx
42+
│ ├── styles css
43+
│ ├── utils 公共方法
44+
│ ├── views 视图单页
45+
│ ├── App.vue 根组件
46+
│ └── main.js 入口
47+
├── .env.development 开发接口
48+
├── .env.production 生产接口
49+
├── babel.config.js
50+
├── package.json
51+
├── postcss.config.js
52+
├── README.md
53+
└── vue.config.js
1754
```
1855

1956
## 开发
@@ -28,12 +65,28 @@ cd vue-vant-mobile
2865
# 安装依赖
2966
npm i
3067

68+
# 启动
69+
npm start
3170
```
3271

3372
浏览器访问 http://localhost:9538
3473

74+
## svg 使用
75+
76+
> 直接去阿里巴巴图标库,找到自己需要的图片下载 svg 格式
77+
> 如果需要改颜色, 请打开 svg 图片源码, 删除源码中的 fill 属性
78+
3579
## 接口
3680

81+
> 本模板默认配置的 "/api" 代理, 如果不需要代理的,直接去掉 vue.config.js 的 proxy 和它对应的值全部删除掉,
82+
> 接着在 utils 文件夹下,把下边的代码放开,关闭另一个代理的
83+
> 配置代理的部署线上服务的时候,记得配置 ngiux 的代理接口转发,否则拿不到数据
84+
85+
```javascript
86+
// 如果不配置代理,就用这个
87+
baseURL: process.env.VUE_APP_BASE_URL,
88+
```
89+
3790
```bash
3891

3992
# 配置开发接口地址

package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"scripts": {
66
"start": "vue-cli-service serve",
77
"build": "vue-cli-service build",
8+
"devbuild": "vue-cli-service --mode=development build",
9+
"preview": "serve -S dist",
810
"lint": "vue-cli-service lint",
911
"test:unit": "vue-cli-service test:unit"
1012
},
@@ -35,6 +37,7 @@
3537
"prettier": "^1.18.2",
3638
"sass": "^1.19.0",
3739
"sass-loader": "^8.0.0",
40+
"script-ext-html-webpack-plugin": "^2.1.4",
3841
"svg-sprite-loader": "^4.1.6",
3942
"vue-template-compiler": "^2.6.10"
4043
}

src/utils/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const toast = () =>
1212
});
1313

1414
const instance = axios.create({
15-
//baseURL: "http://yapi.demo.qunar.com/mock/23750/api", // 如果不配置代理,就用这个
15+
//baseURL: process.env.VUE_APP_BASE_URL, // 如果不配置代理,就用这个
1616
baseURL: "/api", // 如果配置代理就用这个
1717
timeout: 3500
1818
});

vue.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ function resolve(dir) {
44
return path.join(__dirname, dir);
55
}
66

7-
const port = process.env.port || process.env.npm_config_port || 9538; // dev port
7+
const port = 9538;
88

99
module.exports = {
10-
publicPath: process.env.NODE_ENV === "production" ? "/vue-vant-mobile" : "/",
10+
publicPath: "/",
1111
outputDir: "dist",
1212
assetsDir: "static",
1313
lintOnSave: process.env.NODE_ENV === "development",

0 commit comments

Comments
 (0)