feat(Notify): support component call (#6453)

This commit is contained in:
neverland
2020-06-03 20:32:02 +08:00
committed by GitHub
parent 61919d0bec
commit 97541eedfa
9 changed files with 138 additions and 16 deletions
+30 -2
View File
@@ -41,9 +41,9 @@ Notify({
});
```
### \$notify Method
### Global Method
After import the Notify component, the \$notify method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
After import the Notify component, the `$notify` method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
```js
export default {
@@ -53,6 +53,34 @@ export default {
};
```
### Component Call
```html
<van-button type="primary" text="Component Call" @click="showNotify" />
<van-notify v-model="show" type="success">
<van-icon name="bell" style="margin-right: 4px;" />
<span>Content</span>
</van-notify>
```
```js
export default {
data() {
return {
show: false,
};
},
methods: {
showNotify() {
this.show = true;
setTimeout(() => {
this.show = false;
}, 2000);
},
},
};
```
## API
### Methods