mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] Toast: add get-container prop (#2724)
This commit is contained in:
parent
c778a50cd4
commit
ba811b50b0
@ -140,18 +140,22 @@ export default {
|
|||||||
|
|
||||||
move() {
|
move() {
|
||||||
let container;
|
let container;
|
||||||
|
|
||||||
const { getContainer } = this;
|
const { getContainer } = this;
|
||||||
|
|
||||||
if (getContainer) {
|
if (getContainer) {
|
||||||
container =
|
if (typeof getContainer === 'string') {
|
||||||
typeof getContainer === 'string'
|
container =
|
||||||
? document.querySelector(getContainer)
|
getContainer === 'body'
|
||||||
: getContainer();
|
? document.body
|
||||||
|
: document.querySelector(getContainer);
|
||||||
|
} else {
|
||||||
|
container = getContainer();
|
||||||
|
}
|
||||||
} else if (this.$parent) {
|
} else if (this.$parent) {
|
||||||
container = this.$parent.$el;
|
container = this.$parent.$el;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container) {
|
if (container && container !== this.$el.parentNode) {
|
||||||
container.appendChild(this.$el);
|
container.appendChild(this.$el);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -106,3 +106,4 @@ toast2.clear();
|
|||||||
| loadingType | Loading icon type, can be set to `spinner` | `String` | `circular` |
|
| loadingType | Loading icon type, can be set to `spinner` | `String` | `circular` |
|
||||||
| duration | Toast duration(ms), won't disappear if value is 0 | `Number` | `3000` |
|
| duration | Toast duration(ms), won't disappear if value is 0 | `Number` | `3000` |
|
||||||
| className | Custom className | `String | Array | Object` | - |
|
| className | Custom className | `String | Array | Object` | - |
|
||||||
|
| get-container | Return the mount node for Popup | `String | () => HTMLElement` | `body` |
|
||||||
|
@ -5,14 +5,15 @@ import { isObj, isServer } from '../utils';
|
|||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
mask: false,
|
mask: false,
|
||||||
message: '',
|
|
||||||
value: true,
|
value: true,
|
||||||
duration: 3000,
|
message: '',
|
||||||
className: '',
|
className: '',
|
||||||
|
duration: 3000,
|
||||||
position: 'middle',
|
position: 'middle',
|
||||||
loadingType: 'circular',
|
|
||||||
forbidClick: false,
|
forbidClick: false,
|
||||||
overlayStyle: {}
|
loadingType: 'circular',
|
||||||
|
getContainer: 'body',
|
||||||
|
overlayStyle: null
|
||||||
};
|
};
|
||||||
const parseOptions = message => (isObj(message) ? message : { message });
|
const parseOptions = message => (isObj(message) ? message : { message });
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ toast2.clear();
|
|||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
|------|------|------|------|------|
|
|------|------|------|------|------|
|
||||||
| type | 提示类型,可选值为 `loading` `success` `fail` `html` | `String` | `text` | - |
|
| type | 提示类型,可选值为 `loading` `success`<br>`fail` `html` | `String` | `text` | - |
|
||||||
| position | 位置,可选值为 `top` `middle` `bottom` | `String` | `middle` | - |
|
| position | 位置,可选值为 `top` `middle` `bottom` | `String` | `middle` | - |
|
||||||
| message | 内容 | `String` | `''` | - | - |
|
| message | 内容 | `String` | `''` | - | - |
|
||||||
| mask | 是否显示背景蒙层 | `Boolean` | `false` | - |
|
| mask | 是否显示背景蒙层 | `Boolean` | `false` | - |
|
||||||
@ -103,3 +103,4 @@ toast2.clear();
|
|||||||
| loadingType | 加载图标类型, 可选值为 `spinner` | `String` | `circular` | 1.1.3 |
|
| loadingType | 加载图标类型, 可选值为 `spinner` | `String` | `circular` | 1.1.3 |
|
||||||
| duration | 展示时长(ms),值为 0 时,toast 不会消失 | `Number` | `3000` | - |
|
| duration | 展示时长(ms),值为 0 时,toast 不会消失 | `Number` | `3000` | - |
|
||||||
| className | 自定义类名 | `String | Array | Object` | - | 1.6.0 |
|
| className | 自定义类名 | `String | Array | Object` | - | 1.6.0 |
|
||||||
|
| getContainer | 指定挂载的节点,可以传入选择器,<br>或一个返回节点的函数 | `String | () => HTMLElement` | `body` | 1.6.3 |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user