Skip to content

Commit 090214b

Browse files
committed
update docs
1 parent 93ae2f1 commit 090214b

File tree

2 files changed

+107
-18
lines changed

2 files changed

+107
-18
lines changed

README.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
Ant Design Pro Vue
2-
====
1+
<h1 align="center">Ant Design Pro Vue</h1>
32

3+
<div align="center">
4+
An out-of-box UI solution for enterprise applications as a Vue boilerplate. based on [Ant Design of Vue](https://vuecomponent.github.io/ant-design-vue/docs/vue/introduce-cn/)
5+
</div>
46

57

68
Overview
@@ -33,8 +35,10 @@ Overview
3335
![权限结构](https://static-2.loacg.com/open/static/github/permissions.png)
3436

3537

38+
3639
环境和依赖
3740
----
41+
3842
- node
3943
- yarn
4044
- webpack
@@ -45,6 +49,8 @@ Overview
4549
- [@antv/g2](https://antv.alipay.com/zh-cn/index.html) - Alipay AntV 数据可视化图表
4650
- [Viser-vue](https://viserjs.github.io/docs.html#/viser/guide/installation) - antv/g2 封装实现
4751

52+
> 请注意,我们强烈建议本项目使用 [Yarn](https://yarnpkg.com/) 包管理工具,这样可以与本项目演示站所加载完全相同的依赖版本 (yarn.lock) 。由于我们没有对依赖进行强制的版本控制,采用非 yarn 包管理进行引入时,可能由于 Pro 所依赖的库已经升级版本,而引入了新版本所照成的问题。本作者可能会由于时间问题无法及时排查而导致您采用本项目作为基项目而出现问题。
53+
4854

4955

5056
项目下载和运行
@@ -81,11 +87,13 @@ yarn run lint
8187
其他说明
8288
----
8389

90+
- **关于 Issue 反馈 (重要!重要!重要!) 请在开 *Issue* 时,描述清楚您的使用环境,所使用 Pro 版本或分支,出现的情况等...** 另外,若有疑问也可加入 QQ群 (Ant Design Vue 原作者使用讨论群 217490093),本项目的几位维护者也在该群
91+
8492
- 项目使用的 [vue-cli3](https://cli.vuejs.org/guide/), 请更新您的 cli
8593

8694
- 关闭 Eslint (不推荐) 移除 `package.json``eslintConfig` 整个节点代码
8795

88-
- 项目使用了在线 mock,[easy-mock](https://www.easy-mock.com/) 项目所用的 mock 数据 [点击查看(请勿改动接口返回数据)](https://www.easy-mock.com/project/5b7bce071f130e5b7fe8cd7d)
96+
- 项目使用了在线 mock,[easy-mock](https://www.easy-mock.com/) 项目所用的 mock 数据 [点击查看(请勿改动接口返回数据)](https://www.easy-mock.com/project/5b7bce071f130e5b7fe8cd7d),也可以下载 [ANTD-PRO-Easy-Mock-API.zip](https://github.com/sendya/ant-design-pro-vue/files/2682711/ANTD-PRO-Easy-Mock-API.zip) 然后自行导入到自己的 mock 服务上
8997

9098
- 修改 Ant Design 配色,在文件 `vue.config.js` 中,其他 less 变量覆盖参考 [ant design](https://ant.design/docs/react/customize-theme-cn) 官方说明
9199
```ecmascript 6
@@ -104,21 +112,6 @@ yarn run lint
104112
}
105113
}
106114
```
107-
- 按需加载 修改文件 `babel.config.js` 并且引入 `babel-plugin-import` 开发依赖
108-
```ecmascript 6
109-
module.exports = {
110-
presets: [
111-
'@vue/app'
112-
],
113-
plugins: [
114-
[ "import", {
115-
"libraryName": "ant-design-vue",
116-
"libraryDirectory": "es",
117-
"style": "css"
118-
} ]
119-
]
120-
}
121-
```
122115

123116

124117
附属文档
@@ -130,6 +123,8 @@ module.exports = {
130123

131124
- [ANTD 默认配置项](https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultSettings.js)
132125

126+
- [按需加载/减少打包大小](https://github.com/sendya/ant-design-pro-vue/blob/master/docs/LoadOnDemand.md)
127+
133128
- 其他待补充...
134129

135130

docs/LoadOnDemand.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
按需加载 减小打包
2+
====
3+
4+
5+
6+
## 按需引入组件依赖
7+
8+
`Ant Design Pro Vue` 默认编码工作并不支持按需引入,不过可以通过以下操作结合 [Ant Design Of Vue](https://vuecomponent.github.io/ant-design-vue/docs/vue/introduce-cn/) 官方文档来进行按需引入。
9+
10+
1. 增加项目按需引入依赖
11+
2. 修改引入组件方式
12+
13+
14+
15+
1. 增加按需引入所需依赖 `babel-plugin-import`
16+
并且修改文件 `babel.config.js`
17+
```ecmascript 6
18+
module.exports = {
19+
presets: [
20+
'@vue/app'
21+
],
22+
plugins: [
23+
[ "import", {
24+
"libraryName": "ant-design-vue",
25+
"libraryDirectory": "es",
26+
"style": "css"
27+
} ]
28+
]
29+
}
30+
```
31+
32+
33+
2. 修改引入组件方式 (注意,这只是一个例子,请完整引入你所需要的组件)
34+
35+
文件 `@/components/use.js`
36+
37+
```javascript
38+
import Vue from 'vue'
39+
import {
40+
Input,
41+
Button,
42+
Select,
43+
Card,
44+
Form,
45+
Row,
46+
Col,
47+
Modal,
48+
Table,
49+
notification
50+
} from 'ant-design-vue'
51+
52+
Vue.use(Input)
53+
Vue.use(Button)
54+
Vue.use(Select)
55+
Vue.use(Card)
56+
Vue.use(Form)
57+
Vue.use(Row)
58+
Vue.use(Col)
59+
Vue.use(Modal)
60+
Vue.use(Table)
61+
Vue.use(notification)
62+
63+
Vue.prototype.$notification = notification;
64+
```
65+
66+
67+
3. 最后在 `main.js` 中引入 `@/components/use.js` 文件即可,如下
68+
69+
```javascript
70+
71+
import Vue from 'vue'
72+
import App from './App'
73+
74+
// 引入 按需组件的统一引入文件
75+
import './components/use'
76+
77+
import './style/index.less'
78+
79+
80+
Vue.config.productionTip = false
81+
82+
new Vue({
83+
render: h => h(App),
84+
}).$mount('#app')
85+
86+
```
87+
88+
89+
## 其他 减少打包大小
90+
91+
92+
93+
1. Ant Design Vue 1.2.x 版本起,采用的 ant-design 官方方案 svg Icon 组件,整个项目打包会变大很多,图标进行按需加载可参考 https://github.com/HeskeyBaozi/reduce-antd-icons-bundle-demo
94+
2. moment 按需加载 可参考 https://github.com/jmblog/how-to-optimize-momentjs-with-webpack

0 commit comments

Comments
 (0)