Merge branch '2.x' into dev
This commit is contained in:
+23
-5
@@ -72,7 +72,7 @@ Toast({
|
||||
|
||||
```js
|
||||
const toast = Toast.loading({
|
||||
duration: 0, // continuous display toast
|
||||
duration: 0,
|
||||
forbidClick: true,
|
||||
loadingType: 'spinner',
|
||||
message: '3 seconds',
|
||||
@@ -121,16 +121,12 @@ toast2.clear();
|
||||
The Toast default configuration can be globally modified with the `Toast.setDefaultOptions` function.
|
||||
|
||||
```js
|
||||
// Set the duration of all Toast to 2000 ms
|
||||
Toast.setDefaultOptions({ duration: 2000 });
|
||||
|
||||
// Set all loading types Toast to background unclickable
|
||||
Toast.setDefaultOptions('loading', { forbidClick: true });
|
||||
|
||||
// Reset default options of all Toast
|
||||
Toast.resetDefaultOptions();
|
||||
|
||||
// Reset default options of all loading Toast
|
||||
Toast.resetDefaultOptions('loading');
|
||||
```
|
||||
|
||||
@@ -169,3 +165,25 @@ Toast.resetDefaultOptions('loading');
|
||||
| onClose | Callback function after close | _Function_ | - |
|
||||
| transition | Transition, equivalent to `name` prop of [transtion](https://v3.vuejs.org/api/built-in-components.html#transition) | _string_ | `van-fade` |
|
||||
| teleport | Return the mount node for Toast | _string \| Element_ | `body` |
|
||||
|
||||
### Less Variables
|
||||
|
||||
How to use: [Custom Theme](#/en-US/theme).
|
||||
|
||||
| Name | Default Value | Description |
|
||||
| ------------------------------- | ------------------------- | ----------- |
|
||||
| @toast-max-width | `70%` | - |
|
||||
| @toast-font-size | `@font-size-md` | - |
|
||||
| @toast-text-color | `@white` | - |
|
||||
| @toast-loading-icon-color | `@white` | - |
|
||||
| @toast-line-height | `@line-height-md` | - |
|
||||
| @toast-border-radius | `@border-radius-lg` | - |
|
||||
| @toast-background-color | `fade(@black, 70%)` | - |
|
||||
| @toast-icon-size | `36px` | - |
|
||||
| @toast-text-min-width | `96px` | - |
|
||||
| @toast-text-padding | `@padding-xs @padding-sm` | - |
|
||||
| @toast-default-padding | `@padding-md` | - |
|
||||
| @toast-default-width | `88px` | - |
|
||||
| @toast-default-min-height | `88px` | - |
|
||||
| @toast-position-top-distance | `20%` | - |
|
||||
| @toast-position-bottom-distance | `20%` | - |
|
||||
|
||||
@@ -57,7 +57,6 @@ Toast({
|
||||
icon: 'https://img.yzcdn.cn/vant/logo.png',
|
||||
});
|
||||
|
||||
// 自定义加载图标
|
||||
Toast.loading({
|
||||
message: '加载中...',
|
||||
forbidClick: true,
|
||||
@@ -87,7 +86,7 @@ Toast({
|
||||
|
||||
```js
|
||||
const toast = Toast.loading({
|
||||
duration: 0, // 持续展示 toast
|
||||
duration: 0,
|
||||
forbidClick: true,
|
||||
message: '倒计时 3 秒',
|
||||
});
|
||||
@@ -99,7 +98,6 @@ const timer = setInterval(() => {
|
||||
toast.message = `倒计时 ${second} 秒`;
|
||||
} else {
|
||||
clearInterval(timer);
|
||||
// 手动清除 Toast
|
||||
Toast.clear();
|
||||
}
|
||||
}, 1000);
|
||||
@@ -136,16 +134,12 @@ toast2.clear();
|
||||
通过 `Toast.setDefaultOptions` 函数可以全局修改 Toast 的默认配置。
|
||||
|
||||
```js
|
||||
// 将所有 Toast 的展示时长设置为 2000 毫秒
|
||||
Toast.setDefaultOptions({ duration: 2000 });
|
||||
|
||||
// 将所有 loading Toast 设置为背景不可点击
|
||||
Toast.setDefaultOptions('loading', { forbidClick: true });
|
||||
|
||||
// 重置所有 Toast 的默认配置
|
||||
Toast.resetDefaultOptions();
|
||||
|
||||
// 重置 loading Toast 的默认配置
|
||||
Toast.resetDefaultOptions('loading');
|
||||
```
|
||||
|
||||
@@ -167,7 +161,7 @@ Toast.resetDefaultOptions('loading');
|
||||
### Options
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| type | 提示类型,可选值为 `loading` `success`<br>`fail` `html` | _string_ | `text` |
|
||||
| position | 位置,可选值为 `top` `bottom` | _string_ | `middle` |
|
||||
| message | 文本内容,支持通过`\n`换行 | _string_ | `''` | - |
|
||||
@@ -184,3 +178,25 @@ Toast.resetDefaultOptions('loading');
|
||||
| onClose | 关闭时的回调函数 | _Function_ | - |
|
||||
| transition | 动画类名,等价于 [transtion](https://v3.cn.vuejs.org/api/built-in-components.html#transition) 的`name`属性 | _string_ | `van-fade` |
|
||||
| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` |
|
||||
|
||||
### 样式变量
|
||||
|
||||
组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考[主题定制](#/zh-CN/theme)。
|
||||
|
||||
| 名称 | 默认值 | 描述 |
|
||||
| ------------------------------- | ------------------------- | ---- |
|
||||
| @toast-max-width | `70%` | - |
|
||||
| @toast-font-size | `@font-size-md` | - |
|
||||
| @toast-text-color | `@white` | - |
|
||||
| @toast-loading-icon-color | `@white` | - |
|
||||
| @toast-line-height | `@line-height-md` | - |
|
||||
| @toast-border-radius | `@border-radius-lg` | - |
|
||||
| @toast-background-color | `fade(@black, 70%)` | - |
|
||||
| @toast-icon-size | `36px` | - |
|
||||
| @toast-text-min-width | `96px` | - |
|
||||
| @toast-text-padding | `@padding-xs @padding-sm` | - |
|
||||
| @toast-default-padding | `@padding-md` | - |
|
||||
| @toast-default-width | `88px` | - |
|
||||
| @toast-default-min-height | `88px` | - |
|
||||
| @toast-position-top-distance | `20%` | - |
|
||||
| @toast-position-bottom-distance | `20%` | - |
|
||||
|
||||
Reference in New Issue
Block a user