Skip to content

Commit

Permalink
docs: add full registration guide (#12628)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Feb 13, 2024
1 parent 819b1cb commit 3fcd1b9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/vant/docs/markdown/advanced-usage.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ app.use(Button);
app.component(Button.name, Button);
```

#### Full Registration

You can also globally register all Vant components at once:

```js
import Vant from 'vant';
import { createApp } from 'vue';

const app = createApp();

app.use(Vant);

// The Lazyload directive needs to be registered separately
app.use(vant.Lazyload);
```

> Note: Registering all components will introduce the code of all components, leading to larger bundle size.
#### Local Registration

```js
Expand Down
18 changes: 18 additions & 0 deletions packages/vant/docs/markdown/advanced-usage.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ app.use(Button);
app.component(Button.name, Button);
```

#### 全量注册

你也可以在全局一次性注册所有 Vant 组件:

```js
import Vant from 'vant';
import { createApp } from 'vue';

const app = createApp();

app.use(Vant);

// Lazyload 指令需要单独进行注册
app.use(vant.Lazyload);
```

> 注意:注册所有组件会引入所有组件的代码,导致包体积增大。
#### 局部注册

局部注册后,你可以在当前组件中使用注册的 Vant 组件。
Expand Down

0 comments on commit 3fcd1b9

Please sign in to comment.