docs: add component registration guide (#8375)

This commit is contained in:
neverland
2021-03-18 09:55:19 +08:00
committed by GitHub
parent 61b8cf2dec
commit e6e82918e6
2 changed files with 78 additions and 0 deletions
+39
View File
@@ -1,5 +1,44 @@
# Advanced Usage
### Intro
Through this chapter, you can learn about some advanced usages of Vant.
## Component Usage
### Component Registration
Vant supports multiple ways to register components:
#### Global Registration
```js
import { Button } from 'vant';
import { createApp } from 'vue';
const app = createApp();
// Method 1. via app.use
app.use(Button);
// Method 2. Register via app.component
app.component(Button.name, Button);
```
#### Local Registration
```js
import { Button } from 'vant';
export default {
components: {
[Button.name]: Button,
},
};
```
> For more information, please refer to [Vue.js - Component Registration](https://v3.vuejs.org/guide/component-registration.html#component-registration)。
## Browser adaptation
### Viewport Units