mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
[Improment] add $toast/$dialog to Vue.prototype (#363)
This commit is contained in:
@@ -35,8 +35,8 @@ Vue.component(Button.name, Button);
|
||||
#### Loading
|
||||
|
||||
```html
|
||||
<van-button loading></van-button>
|
||||
<van-button loading type="primary"></van-button>
|
||||
<van-button loading />
|
||||
<van-button loading type="primary" />
|
||||
```
|
||||
|
||||
#### Custom Tag
|
||||
|
@@ -40,6 +40,19 @@ Used to confirm some messages, including a confirm button and a cancel button
|
||||
});
|
||||
```
|
||||
|
||||
#### $dialog Method
|
||||
After import the Dialog component, the $dialog method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
|
||||
|
||||
```js
|
||||
export default {
|
||||
mounted() {
|
||||
this.$dialog.alert({
|
||||
message: 'Content'
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
| Name | Attribute | Return value | Description |
|
||||
|
@@ -51,6 +51,17 @@ const timer = setInterval(() => {
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
#### $toast Method
|
||||
After import the Toast component, the $toast method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
|
||||
|
||||
```js
|
||||
export default {
|
||||
mounted() {
|
||||
this.$toast('Some messages');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
| Methods | Attribute | Return value | Description |
|
||||
|
@@ -41,8 +41,8 @@ Vue.component(Button.name, Button);
|
||||
#### 加载状态
|
||||
|
||||
```html
|
||||
<van-button loading></van-button>
|
||||
<van-button loading type="primary"></van-button>
|
||||
<van-button loading />
|
||||
<van-button loading type="primary" />
|
||||
```
|
||||
|
||||
#### 自定义按钮标签
|
||||
|
@@ -40,6 +40,19 @@ Dialog.confirm({
|
||||
});
|
||||
```
|
||||
|
||||
#### 组件内调用
|
||||
引入 Dialog 组件后,会自动在 Vue 的 prototype 上挂载 $dialog 方法,便于在组件内调用。
|
||||
|
||||
```js
|
||||
export default {
|
||||
mounted() {
|
||||
this.$dialog.alert({
|
||||
message: '弹窗内容'
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 方法
|
||||
|
||||
| 方法名 | 参数 | 返回值 | 介绍 |
|
||||
|
@@ -51,6 +51,18 @@ const timer = setInterval(() => {
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
#### 组件内调用
|
||||
引入 Toast 组件后,会自动在 Vue 的 prototype 上挂载 $toast 方法,便于在组件内调用。
|
||||
|
||||
```js
|
||||
export default {
|
||||
mounted() {
|
||||
this.$toast('提示文案');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 方法
|
||||
|
||||
|
Reference in New Issue
Block a user