Skip to content

Commit 118ae9a

Browse files
docs: v4 vuedocs (#6468)
* fix introduce doc * fix getting-started doc * add migration-v4 doc * fix docs * Update migration-v4.zh-CN.md * Update migration-v4.zh-CN.md * Update migration-v4.en-US.md * Update migration-v4.zh-CN.md * Update getting-started.en-US.md * Update getting-started.zh-CN.md * Update introduce.en-US.md * Update introduce.zh-CN.md --------- Co-authored-by: tangjinzhou <[email protected]>
1 parent 0683ede commit 118ae9a

7 files changed

+395
-168
lines changed

site/src/router/index.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ const routes = [
116116
meta: { enTitle: 'Dynamic Theme (Experimental)', title: '动态主题', category: 'docs' },
117117
component: () => import('../vueDocs/customize-theme-variable.en-US.md'),
118118
},
119+
{
120+
path: 'vue/replace-date-cn',
121+
meta: { enTitle: 'Custom Date Library', title: '自定义时间库', category: 'docs' },
122+
component: () => import('../vueDocs/replace-date.zh-CN.md'),
123+
},
124+
{
125+
path: 'vue/replace-date',
126+
meta: { enTitle: 'Custom Date Library', title: '自定义时间库', category: 'docs' },
127+
component: () => import('../vueDocs/replace-date.en-US.md'),
128+
},
119129
{
120130
path: 'vue/migration-v2-cn',
121131
meta: { enTitle: 'V1 to V2', title: '从 v1 到 v2', category: 'docs' },
@@ -137,14 +147,14 @@ const routes = [
137147
component: () => import('../vueDocs/migration-v3.en-US.md'),
138148
},
139149
{
140-
path: 'vue/replace-date-cn',
141-
meta: { enTitle: 'Custom Date Library', title: '自定义时间库', category: 'docs' },
142-
component: () => import('../vueDocs/replace-date.zh-CN.md'),
150+
path: 'vue/migration-v4-cn',
151+
meta: { enTitle: 'V3 to V4', title: '从 V3 到 V4', category: 'docs' },
152+
component: () => import('../vueDocs/migration-v4.zh-CN.md'),
143153
},
144154
{
145-
path: 'vue/replace-date',
146-
meta: { enTitle: 'Custom Date Library', title: '自定义时间库', category: 'docs' },
147-
component: () => import('../vueDocs/replace-date.en-US.md'),
155+
path: 'vue/migration-v4',
156+
meta: { enTitle: 'V3 to V4', title: '从 V3 到 V4', category: 'docs' },
157+
component: () => import('../vueDocs/migration-v4.en-US.md'),
148158
},
149159
{
150160
path: 'vue/i18n-cn',

site/src/vueDocs/getting-started.en-US.md

+3-29
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ And, setup your vue project configuration.
3737
#### Install
3838

3939
```bash
40-
$ npm i --save ant-design-vue
40+
$ npm i --save ant-design-vue@4.x
4141
```
4242

4343
#### Component Registration
@@ -50,7 +50,7 @@ If you use Vue's default template syntax, you need to register components before
5050
import { createApp } from 'vue';
5151
import Antd from 'ant-design-vue';
5252
import App from './App';
53-
import 'ant-design-vue/dist/antd.css';
53+
import 'ant-design-vue/dist/reset.css';
5454

5555
const app = createApp(App);
5656

@@ -99,35 +99,9 @@ In this way, component sub-components, such as Button and ButtonGroup, need to b
9999

100100
[Component list](https://github.com/vueComponent/ant-design-vue/blob/main/components/components.ts)
101101

102-
## Compatibility
103-
104-
Ant Design Vue 2.x supports all the modern browsers. If you want to use IE9+, you can use Ant Design Vue 1.x & Vue 2.x.
105-
106102
## Import on Demand
107103

108-
we can import individual components on demand:
109-
110-
```jsx
111-
import Button from 'ant-design-vue/lib/button';
112-
import 'ant-design-vue/lib/button/style'; // or ant-design-vue/lib/button/style/css for css format file
113-
```
114-
115-
We strongly recommend using [babel-plugin-import](https://github.com/ant-design/babel-plugin-import), which can convert the following code to the 'ant-design-vue/lib/xxx' way:
116-
117-
```jsx
118-
import { Button } from 'ant-design-vue';
119-
```
120-
121-
And this plugin can load styles too, read [usage](https://github.com/ant-design/babel-plugin-import#usage) for more details.
122-
123-
> FYI, babel-plugin-import's `style` option will importing some global reset styles, don't use it if you don't need those styles. You can import styles manually via `import 'ant-design-vue/dist/antd.css'` and override the global reset styles.
124-
125-
If you use Vite, you can use [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) to load on demand. However, this plugin can only deal with components. Others such as message should be loaded manually:
126-
127-
```ts
128-
import { message } from 'ant-design-vue';
129-
import 'ant-design-vue/es/message/style/css'; //use ant-design-vue/es instead of ant-design-vue/lib
130-
```
104+
`ant-design-vue` supports tree shaking of ES modules, so using `import { Button } from 'ant-design-vue';` would drop js code you didn't use.
131105

132106
## Customization
133107

site/src/vueDocs/getting-started.zh-CN.md

+3-31
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $ vue create antd-demo
3939
#### 安装
4040

4141
```bash
42-
$ npm i --save ant-design-vue
42+
$ npm i --save ant-design-vue@4.x
4343
```
4444

4545
#### 注册
@@ -52,7 +52,7 @@ $ npm i --save ant-design-vue
5252
import { createApp } from 'vue';
5353
import Antd from 'ant-design-vue';
5454
import App from './App';
55-
import 'ant-design-vue/dist/antd.css';
55+
import 'ant-design-vue/dist/reset.css';
5656

5757
const app = createApp(App);
5858

@@ -97,37 +97,9 @@ app.config.globalProperties.$message = message;
9797
</script>
9898
```
9999

100-
## 兼容性
101-
102-
Ant Design Vue 2.x+ 支持所有的现代浏览器。
103-
104-
如果需要支持 IE9+,你可以使用 Ant Design Vue 1.x & Vue 2.x。
105-
106100
## 按需加载
107101

108-
如果你仅需要加载使用的组件,可以通过以下的写法来按需加载组件。
109-
110-
```jsx
111-
import Button from 'ant-design-vue/lib/button';
112-
import 'ant-design-vue/lib/button/style'; // 或者 ant-design-vue/lib/button/style/css 加载 css 文件
113-
```
114-
115-
如果你使用了 babel,那么可以使用 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 来进行按需加载,加入这个插件后。你可以仍然这么写:
116-
117-
```jsx
118-
import { Button } from 'ant-design-vue';
119-
```
120-
121-
插件会帮你转换成 `ant-design-vue/lib/xxx` 的写法。另外此插件配合 [style](https://github.com/ant-design/babel-plugin-import#usage) 属性可以做到模块样式的按需自动加载。
122-
123-
> 注意,babel-plugin-import 的 `style` 属性除了引入对应组件的样式,也会引入一些必要的全局样式。如果你不需要它们,建议不要使用此属性。你可以 `import 'ant-design-vue/dist/antd.css` 手动引入,并覆盖全局样式。
124-
125-
如果你使用的 Vite,你可以使用 [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) 来进行按需加载。但是此插件无法处理非组件模块,如 message,这种组件需要手动加载:
126-
127-
```ts
128-
import { message } from 'ant-design-vue';
129-
import 'ant-design-vue/es/message/style/css'; //vite只能用 ant-design-vue/es 而非 ant-design-vue/lib
130-
```
102+
`ant-design-vue` 默认支持基于 ES modules 的 tree shaking,直接引入 `import { Button } from 'ant-design-vue';` 就会有按需加载的效果。
131103

132104
## 配置主题和字体
133105

site/src/vueDocs/introduce.en-US.md

+9-51
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ You can subscribe to this feed for new version notifications: https://github.com
4949
**We recommend using npm or yarn to install**,it not only makes development easier,but also allow you to take advantage of the rich ecosystem of Javascript packages and tooling.
5050

5151
```bash
52-
$ npm install ant-design-vue --save
52+
$ npm install ant-design-vue@4.x --save
5353
```
5454

5555
```bash
56-
$ yarn add ant-design-vue
56+
$ yarn add ant-design-vue@4.x
5757
```
5858

5959
If you are in a bad network environment,you can try other registries and tools like [cnpm](https://github.com/cnpm/cnpm).
@@ -62,11 +62,11 @@ If you are in a bad network environment,you can try other registries and tools
6262

6363
Add `script` and `link` tags in your browser and use the global variable `antd`.
6464

65-
We provide `antd.js` `antd.css` and `antd.min.js` `antd.min.css` under `ant-design-vue/dist` in antd's npm package. You can also download these files directly from [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/ant-design-vue/badge)](https://www.jsdelivr.com/package/npm/ant-design-vue) or [unpkg](https://unpkg.com/ant-design-vue/dist/).
65+
We provide `antd.js` `antd.min.js` and `reset.css` under `ant-design-vue/dist` in antd's npm package. You can also download these files directly from [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/ant-design-vue/badge)](https://www.jsdelivr.com/package/npm/ant-design-vue) or [unpkg](https://unpkg.com/ant-design-vue/dist/).
6666

6767
> **We strongly discourage loading the entire files** this will add bloat to your application and make it more difficult to receive bugfixes and updates. Antd is intended to be used in conjunction with a build tool, such as [webpack](https://webpack.github.io/), which will make it easy to import only the parts of antd that you are using.
6868
69-
> Note: you should import [dayjs](https://day.js.org/) and dayjs plugins before using antd.js.
69+
> Note: you should import `vue`, [dayjs](https://day.js.org/) and dayjs plugins before using `antd.js`.
7070
7171
Like:
7272

@@ -78,6 +78,7 @@ Like:
7878
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
7979
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
8080
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
81+
<script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script>
8182
```
8283

8384
## Usage
@@ -90,55 +91,12 @@ app.use(DatePicker);
9091
And import stylesheets manually:
9192

9293
```jsx
93-
import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less'
94+
import 'ant-design-vue/dist/reset.css';
9495
```
9596

96-
### Use modularized antd
97+
### Use modularized ant-design-vue
9798

98-
- Use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) (Recommended)
99-
100-
```jsx
101-
// .babelrc or babel-loader option
102-
{
103-
"plugins": [
104-
["import", { "libraryName": "ant-design-vue", "libraryDirectory": "es", "style": "css" }] // `style: true` for less
105-
]
106-
}
107-
```
108-
109-
> Note: Don't set `libraryDirectory` if you are using webpack 1.
110-
111-
This allows you to import components from antd without having to manually import the corresponding stylesheet. The antd babel plugin will automatically import stylesheets.
112-
113-
```jsx
114-
// import js and css modularly, parsed by babel-plugin-import
115-
import { DatePicker } from 'ant-design-vue';
116-
```
117-
118-
- Manually import
119-
120-
```jsx
121-
import DatePicker from 'ant-design-vue/lib/date-picker'; // for js
122-
import 'ant-design-vue/lib/date-picker/style/css'; // for css
123-
// import 'ant-design-vue/lib/date-picker/style'; // that will import less
124-
```
125-
126-
- For Vite
127-
128-
```js
129-
// vite.config.js
130-
import Components from 'unplugin-vue-components/vite';
131-
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
132-
133-
export default {
134-
plugins: [
135-
/* ... */
136-
Components({
137-
resolvers: [AntDesignVueResolver()],
138-
}),
139-
],
140-
};
141-
```
99+
`ant-design-vue` supports ES modules tree shaking by default.
142100

143101
## Links
144102

@@ -154,7 +112,7 @@ import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less'
154112

155113
## Contributing
156114

157-
If you'd like to help us improve antd, just create a [Pull Request](https://github.com/vueComponent/ant-design-vue/pulls). Feel free to report bugs and issues [here](https://vuecomponent.github.io/issue-helper/).
115+
If you'd like to help us improve ant-design-vue, just create a [Pull Request](https://github.com/vueComponent/ant-design-vue/pulls). Feel free to report bugs and issues [here](https://vuecomponent.github.io/issue-helper/).
158116

159117
> If you're new to posting issues, we ask that you read [_How To Ask Questions The Smart Way_](http://www.catb.org/~esr/faqs/smart-questions.html) and [How to Ask a Question in Open Source Community](https://github.com/seajs/seajs/issues/545) and [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) prior to posting. Well written bug reports help us help you!
160118

site/src/vueDocs/introduce.zh-CN.md

+7-51
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
**我们推荐使用 npm 或 yarn 的方式进行开发**,不仅可在开发环境轻松调试,也可放心地在生产环境打包部署使用,享受整个生态圈和工具链带来的诸多好处。
5050

5151
```bash
52-
$ npm install ant-design-vue --save
52+
$ npm install ant-design-vue@4.x --save
5353
```
5454

5555
```bash
56-
$ yarn add ant-design-vue
56+
$ yarn add ant-design-vue@4.x
5757
```
5858

5959
如果你的网络环境不佳,推荐使用 [cnpm](https://github.com/cnpm/cnpm)
@@ -62,11 +62,11 @@ $ yarn add ant-design-vue
6262

6363
在浏览器中使用 `script``link` 标签直接引入文件,并使用全局变量 `antd`
6464

65-
我们在 npm 发布包内的 `ant-design-vue/dist` 目录下提供了 `antd.js` `antd.css` 以及 `antd.min.js` `antd.min.css`。你也可以通过 [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/ant-design-vue/badge)](https://www.jsdelivr.com/package/npm/ant-design-vue)[UNPKG](https://unpkg.com/ant-design-vue/dist/) 进行下载。
65+
我们在 npm 发布包内的 `ant-design-vue/dist` 目录下提供了 `antd.js``antd.min.js` `reset.css`。你也可以通过 [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/ant-design-vue/badge)](https://www.jsdelivr.com/package/npm/ant-design-vue)[UNPKG](https://unpkg.com/ant-design-vue/dist/) 进行下载。
6666

6767
> **强烈不推荐使用已构建文件**,这样无法按需加载,而且难以获得底层依赖模块的 bug 快速修复支持。
6868
69-
> 注意:引入 antd.js 前你需要自行引入 [dayjs](https://day.js.org/) 及其相关插件。
69+
> 注意:引入 `antd.js` 前你需要自行引入 `vue`[`dayjs`](https://day.js.org/) 及其相关插件。
7070
7171
如:
7272

@@ -78,6 +78,7 @@ $ yarn add ant-design-vue
7878
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
7979
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
8080
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
81+
<script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script>
8182
```
8283

8384
## 示例
@@ -90,57 +91,12 @@ app.use(DatePicker);
9091
引入样式:
9192

9293
```jsx
93-
import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less'
94+
import 'ant-design-vue/dist/reset.css';
9495
```
9596

9697
### 按需加载
9798

98-
下面两种方式都可以只加载用到的组件。
99-
100-
- 使用 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)(推荐)。
101-
102-
```jsx
103-
// .babelrc or babel-loader option
104-
{
105-
"plugins": [
106-
["import", { "libraryName": "ant-design-vue", "libraryDirectory": "es", "style": "css" }] // `style: true` 会加载 less 文件
107-
]
108-
}
109-
```
110-
111-
> 注意:webpack 1 无需设置 `libraryDirectory`
112-
113-
然后只需从 ant-design-vue 引入模块即可,无需单独引入样式。等同于下面手动引入的方式。
114-
115-
```jsx
116-
// babel-plugin-import 会帮助你加载 JS 和 CSS
117-
import { DatePicker } from 'ant-design-vue';
118-
```
119-
120-
- 手动引入
121-
122-
```jsx
123-
import DatePicker from 'ant-design-vue/lib/date-picker'; // 加载 JS
124-
import 'ant-design-vue/lib/date-picker/style/css'; // 加载 CSS
125-
// import 'ant-design-vue/lib/date-picker/style'; // 加载 LESS
126-
```
127-
128-
- Vite 按需
129-
130-
```js
131-
// vite.config.js
132-
import Components from 'unplugin-vue-components/vite';
133-
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
134-
135-
export default {
136-
plugins: [
137-
/* ... */
138-
Components({
139-
resolvers: [AntDesignVueResolver()],
140-
}),
141-
],
142-
};
143-
```
99+
`ant-design-vue` 默认支持基于 ES modules 的 tree shaking。
144100

145101
## 链接
146102

0 commit comments

Comments
 (0)