@@ -62,7 +62,7 @@ test('click overlay and close', async () => {
},
data() {
return {
- getContainer: () => div,
+ teleport: () => div,
};
},
methods: {
@@ -110,7 +110,7 @@ test('get container', () => {
const wrapper = mount(ActionSheet, {
propsData: {
value: true,
- getContainer: 'body',
+ teleport: 'body',
},
});
diff --git a/src/address-edit/index.js b/src/address-edit/index.js
index 881d8302f..16e3b8386 100644
--- a/src/address-edit/index.js
+++ b/src/address-edit/index.js
@@ -388,9 +388,9 @@ export default createComponent({
{
this.showAreaPopup = value;
diff --git a/src/calendar/README.md b/src/calendar/README.md
index d83201e57..a9a3adb09 100644
--- a/src/calendar/README.md
+++ b/src/calendar/README.md
@@ -258,7 +258,7 @@ Following props are supported when the poppable is true
| close-on-popstate `v2.4.4` | Whether to close when popstate | _boolean_ | `true` |
| close-on-click-overlay | Whether to close when click overlay | _boolean_ | `true` |
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
-| get-container `v2.4.4` | Return the mount node for Calendar | _string \| () => Element_ | - |
+| teleport `v2.4.4` | Return the mount node for Calendar | _string \| Element_ | - |
### Range Props
diff --git a/src/calendar/README.zh-CN.md b/src/calendar/README.zh-CN.md
index ee99ff138..cf5152224 100644
--- a/src/calendar/README.zh-CN.md
+++ b/src/calendar/README.zh-CN.md
@@ -260,7 +260,7 @@ export default {
| close-on-popstate `v2.4.4` | 是否在页面回退时自动关闭 | _boolean_ | `true` |
| close-on-click-overlay | 是否在点击遮罩层后关闭 | _boolean_ | `true` |
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` |
-| get-container `v2.4.4` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport `v2.4.4` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Range Props
diff --git a/src/calendar/index.js b/src/calendar/index.js
index 6f713a613..21468c965 100644
--- a/src/calendar/index.js
+++ b/src/calendar/index.js
@@ -27,11 +27,11 @@ export default createComponent({
show: Boolean,
title: String,
color: String,
+ teleport: [String, Object],
formatter: Function,
confirmText: String,
rangePrompt: String,
defaultDate: [Date, Array],
- getContainer: [String, Function],
allowSameDay: Boolean,
confirmDisabledText: String,
type: {
@@ -487,7 +487,7 @@ export default createComponent({
round={this.round}
position={this.position}
closeable={this.showTitle || this.showSubtitle}
- getContainer={this.getContainer}
+ teleport={this.teleport}
closeOnPopstate={this.closeOnPopstate}
closeOnClickOverlay={this.closeOnClickOverlay}
{...listeners}
diff --git a/src/dialog/README.md b/src/dialog/README.md
index 2e5fcba0b..c5cd39338 100644
--- a/src/dialog/README.md
+++ b/src/dialog/README.md
@@ -159,7 +159,7 @@ export default {
| allowHtml `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `true` |
| beforeClose | Callback before close,
call done() to close dialog,
call done(false) to cancel loading | (action: string, done: Function) => void | - |
| transition `v2.2.6` | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | _string_ | - |
-| getContainer | Return the mount node for Dialog | _string \| () => Element_ | `body` |
+| teleport | Return the mount node for Dialog | _string \| Element_ | `body` |
### Props
@@ -187,7 +187,7 @@ export default {
| allow-html `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `true` |
| before-close | Callback before close,
call done() to close dialog,
call done(false) to cancel loading | (action: string, done: Function) => void | - |
| transition `v2.2.6` | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | _string_ | - |
-| get-container | Return the mount node for Dialog | _string \| () => Element_ | - |
+| teleport | Return the mount node for Dialog | _string \| Element_ | - |
### Events
diff --git a/src/dialog/README.zh-CN.md b/src/dialog/README.zh-CN.md
index cea9787cb..ed9cfdbcf 100644
--- a/src/dialog/README.zh-CN.md
+++ b/src/dialog/README.zh-CN.md
@@ -189,7 +189,7 @@ export default {
| allowHtml `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `true` |
| beforeClose | 关闭前的回调函数,
调用 done() 后关闭弹窗,
调用 done(false) 阻止弹窗关闭 | _(action, done) => void_ | - |
| transition `v2.2.6` | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | _string_ | - |
-| getContainer | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | `body` |
+| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` |
### Props
@@ -219,7 +219,7 @@ export default {
| allow-html `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `true` |
| before-close | 关闭前的回调函数,
调用 done() 后关闭弹窗,
调用 done(false) 阻止弹窗关闭 | _(action, done) => void_ | - |
| transition `v2.2.6` | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | _string_ | - |
-| get-container | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Events
diff --git a/src/dialog/index.js b/src/dialog/index.js
index 9cb4694f9..6758ae102 100644
--- a/src/dialog/index.js
+++ b/src/dialog/index.js
@@ -70,6 +70,7 @@ Dialog.defaultOptions = {
message: '',
overlay: true,
callback: null,
+ teleport: 'body',
className: '',
allowHtml: true,
lockScroll: true,
@@ -78,7 +79,6 @@ Dialog.defaultOptions = {
overlayClass: '',
overlayStyle: null,
messageAlign: '',
- getContainer: 'body',
cancelButtonText: '',
cancelButtonColor: null,
confirmButtonText: '',
diff --git a/src/dropdown-item/index.js b/src/dropdown-item/index.js
index 1c5655c76..e773666d0 100644
--- a/src/dropdown-item/index.js
+++ b/src/dropdown-item/index.js
@@ -95,8 +95,8 @@ export default createComponent({
},
onClickWrapper(event) {
- // prevent being identified as clicking outside and closed when use get-contaienr
- if (this.getContainer) {
+ // prevent being identified as clicking outside and closed when using teleport
+ if (this.teleport) {
event.stopPropagation();
}
},
diff --git a/src/dropdown-menu/README.md b/src/dropdown-menu/README.md
index 4d71ce998..2d1d2010a 100644
--- a/src/dropdown-menu/README.md
+++ b/src/dropdown-menu/README.md
@@ -143,7 +143,7 @@ Use `active-color` prop to custom active color of the title and options
| disabled | Whether to disable dropdown item | _boolean_ | `false` |
| lazy-render `v2.8.5` | Whether to lazy render util opened | _boolean_ | `true` |
| title-class | Title class | _string_ | - |
-| get-container `v2.2.4` | Return the mount node for menu | _string \| () => Element_ | - |
+| teleport `v2.2.4` | Return the mount node for menu | _string \| Element_ | - |
### DropdownItem Events
diff --git a/src/dropdown-menu/README.zh-CN.md b/src/dropdown-menu/README.zh-CN.md
index ce9669d55..8c3eb92fb 100644
--- a/src/dropdown-menu/README.zh-CN.md
+++ b/src/dropdown-menu/README.zh-CN.md
@@ -147,7 +147,7 @@ export default {
| disabled | 是否禁用菜单 | _boolean_ | `false` |
| lazy-render `v2.8.5` | 是否在首次展开时才渲染菜单内容 | _boolean_ | `true` |
| title-class | 标题额外类名 | _string_ | - |
-| get-container `v2.2.4` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport `v2.2.4` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### DropdownItem Events
diff --git a/src/form/demo/FieldTypeArea.vue b/src/form/demo/FieldTypeArea.vue
index f0e0901ed..cbc7f3d65 100644
--- a/src/form/demo/FieldTypeArea.vue
+++ b/src/form/demo/FieldTypeArea.vue
@@ -13,7 +13,7 @@
v-model:show="showArea"
round
position="bottom"
- get-container="body"
+ teleport="body"
>
diff --git a/src/form/demo/FieldTypeDatetimePicker.vue b/src/form/demo/FieldTypeDatetimePicker.vue
index c2f311c48..7d0d0cbcc 100644
--- a/src/form/demo/FieldTypeDatetimePicker.vue
+++ b/src/form/demo/FieldTypeDatetimePicker.vue
@@ -13,7 +13,7 @@
v-model:show="showPicker"
round
position="bottom"
- get-container="body"
+ teleport="body"
>
Element_ | - |
+| teleport | Return the mount node for ImagePreview | _string \| Element_ | - |
### Props
@@ -150,7 +150,7 @@ export default {
| closeable `v2.5.0` | Whether to show close icon | _boolean_ | `false` |
| close-icon `v2.5.0` | Close icon name | _string_ | `clear` |
| close-icon-position `v2.5.0` | Close icon position,can be set to `top-left` `bottom-left` `bottom-right` | _string_ | `top-right` |
-| get-container | Return the mount node for ImagePreview | _string \| () => Element_ | - |
+| teleport | Return the mount node for ImagePreview | _string \| Element_ | - |
### Events
diff --git a/src/image-preview/README.zh-CN.md b/src/image-preview/README.zh-CN.md
index 972e9128d..0aedb9e6c 100644
--- a/src/image-preview/README.zh-CN.md
+++ b/src/image-preview/README.zh-CN.md
@@ -166,7 +166,7 @@ export default {
| closeable `v2.5.0` | 是否显示关闭图标 | _boolean_ | `false` |
| closeIcon `v2.5.0` | 关闭图标名称或图片链接 | _string_ | `clear` |
| closeIconPosition `v2.5.0` | 关闭图标位置,可选值为`top-left`
`bottom-left` `bottom-right` | _string_ | `top-right` |
-| getContainer | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Props
@@ -188,7 +188,7 @@ export default {
| closeable `v2.5.0` | 是否显示关闭图标 | _boolean_ | `false` |
| close-icon `v2.5.0` | 关闭图标名称或图片链接 | _string_ | `clear` |
| close-icon-position `v2.5.0` | 关闭图标位置,可选值为`top-left`
`bottom-left` `bottom-right` | _string_ | `top-right` |
-| get-container | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Events
diff --git a/src/image-preview/index.js b/src/image-preview/index.js
index 1e268e031..1b8f9b3ce 100644
--- a/src/image-preview/index.js
+++ b/src/image-preview/index.js
@@ -12,12 +12,12 @@ const defaultConfig = {
onScale: null,
onClose: null,
onChange: null,
+ teleport: 'body',
className: '',
showIndex: true,
closeable: false,
closeIcon: 'clear',
asyncClose: false,
- getContainer: 'body',
startPosition: 0,
swipeDuration: 500,
showIndicators: false,
diff --git a/src/image-preview/test/index.spec.js b/src/image-preview/test/index.spec.js
index 198afab04..7b68455c0 100644
--- a/src/image-preview/test/index.spec.js
+++ b/src/image-preview/test/index.spec.js
@@ -336,7 +336,7 @@ test('ImagePreview.Component', () => {
test('get container with function call ', async (done) => {
const element = document.createElement('div');
document.body.appendChild(element);
- ImagePreview({ images, getContainer: () => element });
+ ImagePreview({ images, teleport: element });
await Vue.nextTick();
const wrapperDiv = document.querySelector('.van-image-preview');
@@ -358,22 +358,22 @@ test('get container with component call', () => {
const wrapper = mount({
template: `
-
+
`,
data() {
return {
- getContainer: () => div1,
+ teleport: () => div1,
};
},
});
const imageView = wrapper.find('.van-image-preview').element;
expect(imageView.parentNode).toEqual(div1);
- wrapper.vm.getContainer = () => div2;
+ wrapper.vm.teleport = () => div2;
expect(imageView.parentNode).toEqual(div2);
- wrapper.vm.getContainer = null;
+ wrapper.vm.teleport = null;
expect(wrapper.element).toEqual(wrapper.element);
});
diff --git a/src/mixins/portal.js b/src/mixins/portal.js
index ec3e65f26..4d05b786f 100644
--- a/src/mixins/portal.js
+++ b/src/mixins/portal.js
@@ -1,35 +1,35 @@
-function getElement(selector) {
- if (typeof selector === 'string') {
- return document.querySelector(selector);
+function getElement(teleport) {
+ if (typeof teleport === 'string') {
+ return document.querySelector(teleport);
}
- return selector();
+ return teleport;
}
export function PortalMixin({ ref, afterPortal } = {}) {
return {
props: {
- getContainer: [String, Function],
+ teleport: [String, Object],
},
watch: {
- getContainer: 'portal',
+ teleport: 'portal',
},
mounted() {
- if (this.getContainer) {
+ if (this.teleport) {
this.portal();
}
},
methods: {
portal() {
- const { getContainer } = this;
+ const { teleport } = this;
const el = ref ? this.$refs[ref] : this.$el;
let container;
- if (getContainer) {
- container = getElement(getContainer);
+ if (teleport) {
+ container = getElement(teleport);
} else if (this.$parent) {
container = this.$parent.$el;
}
diff --git a/src/notify/Notify.js b/src/notify/Notify.js
index 13c63ecb1..01d3dc32a 100644
--- a/src/notify/Notify.js
+++ b/src/notify/Notify.js
@@ -9,9 +9,9 @@ export default createComponent({
color: String,
message: [Number, String],
duration: [Number, String],
+ teleport: [String, Object],
className: null,
background: String,
- getContainer: [String, Function],
type: {
type: String,
default: 'danger',
diff --git a/src/number-keyboard/README.md b/src/number-keyboard/README.md
index 7da413df3..3af614174 100644
--- a/src/number-keyboard/README.md
+++ b/src/number-keyboard/README.md
@@ -156,7 +156,7 @@ export default {
| close-button-loading `v2.7.0` | Whether to show loading close button in custom theme | _boolean_ | `false` |
| show-delete-key `v2.5.9` | Whether to show delete button | _boolean_ | `true` |
| hide-on-click-outside | Whether to hide keyboard when click outside | _boolean_ | `true` |
-| get-container `v2.10.0` | Return the mount node for NumberKeyboard | _string \| () => Element_ | - |
+| teleport `v2.10.0` | Return the mount node for NumberKeyboard | _string \| Element_ | - |
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
### Events
diff --git a/src/number-keyboard/README.zh-CN.md b/src/number-keyboard/README.zh-CN.md
index c1cf4bef0..0bccdd353 100644
--- a/src/number-keyboard/README.zh-CN.md
+++ b/src/number-keyboard/README.zh-CN.md
@@ -169,7 +169,7 @@ export default {
| close-button-loading `v2.7.0` | 是否将关闭按钮设置为加载中状态,仅在 `theme="custom"` 时有效 | _boolean_ | `false` |
| show-delete-key `v2.5.9` | 是否展示删除图标 | _boolean_ | `true` |
| hide-on-click-outside | 点击外部时是否收起键盘 | _boolean_ | `true` |
-| get-container `v2.10.0` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport `v2.10.0` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` |
### Events
diff --git a/src/popup/README.md b/src/popup/README.md
index f882c2d07..f244f14e5 100644
--- a/src/popup/README.md
+++ b/src/popup/README.md
@@ -83,30 +83,28 @@ Use `position` prop to set popup display position
### Get Container
-Use `get-container` prop to specify mount location
+Use `teleport` prop to specify mount location
```html
-
+
-
+
-
-
+
+
```
```js
export default {
- methods: {
- getContainer() {
- return document.querySelector('.my-container');
- },
+ beforeCreate() {
+ this.myContainer = document.querySelector('.my-container');
},
};
```
-> Tips: The get-container prop cannot be used on the root node
+> Tips: The teleport prop cannot be used on the root node
## API
@@ -129,7 +127,7 @@ export default {
| close-icon `v2.2.0` | Close icon name | _string_ | `cross` |
| close-icon-position `v2.2.2` | Close Icon Position,can be set to `top-left` `bottom-left` `bottom-right` | _string_ | `top-right` |
| transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | _string_ | - |
-| get-container | Return the mount node for Popup | _string \| () => Element_ | - |
+| teleport | Return the mount node for Popup | _string \| Element_ | - |
| safe-area-inset-bottom `v2.2.1` | Whether to enable bottom safe area adaptation | _boolean_ | `false` |
### Events
diff --git a/src/popup/README.zh-CN.md b/src/popup/README.zh-CN.md
index 2eea09eb1..d87252f10 100644
--- a/src/popup/README.zh-CN.md
+++ b/src/popup/README.zh-CN.md
@@ -93,31 +93,28 @@ export default {
### 指定挂载位置
-弹出层默认挂载到组件所在位置,可以通过`get-container`属性指定挂载位置
+弹出层默认挂载到组件所在位置,可以通过`teleport`属性指定挂载位置
```html
-
+
-
+
-
-
+
+
```
```js
export default {
- methods: {
- // 返回一个特定的 DOM 节点,作为挂载的父节点
- getContainer() {
- return document.querySelector('.my-container');
- },
+ beforeCreate() {
+ this.myContainer = document.querySelector('.my-container');
},
};
```
-> 注意:使用 get-container 属性的组件不能为根节点
+> 注意:使用 teleport 属性的组件不能为根节点
## API
@@ -140,7 +137,7 @@ export default {
| close-icon `v2.2.0` | 关闭图标名称或图片链接 | _string_ | `cross` |
| close-icon-position `v2.2.2` | 关闭图标位置,可选值为`top-left`
`bottom-left` `bottom-right` | _string_ | `top-right` |
| transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | _string_ | - |
-| get-container | 指定挂载的节点 | _string \| () => Element_ | - |
+| teleport | 指定挂载的节点 | _string \| Element_ | - |
| safe-area-inset-bottom `v2.2.1` | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `false` |
### Events
diff --git a/src/popup/demo/index.vue b/src/popup/demo/index.vue
index c3260d820..3eb7a8c25 100644
--- a/src/popup/demo/index.vue
+++ b/src/popup/demo/index.vue
@@ -84,15 +84,15 @@
/>
-
+
@@ -109,7 +109,7 @@ export default {
buttonBottom: '底部弹出',
buttonLeft: '左侧弹出',
buttonRight: '右侧弹出',
- getContainer: '指定挂载节点',
+ teleport: '指定挂载节点',
roundCorner: '圆角弹窗',
closeIcon: '关闭图标',
customCloseIcon: '自定义图标',
@@ -122,7 +122,7 @@ export default {
buttonBottom: 'From Bottom',
buttonLeft: 'From Left',
buttonRight: 'From Right',
- getContainer: 'Get Container',
+ teleport: 'Get Container',
roundCorner: 'Round Corner',
closeIcon: 'Close Icon',
customCloseIcon: 'Custom Icon',
diff --git a/src/popup/index.js b/src/popup/index.js
index f97650511..6ae410e67 100644
--- a/src/popup/index.js
+++ b/src/popup/index.js
@@ -33,7 +33,7 @@ export const popupSharedProps = {
// overlay custom class name
overlayClass: String,
// teleport
- getContainer: [String, Function],
+ teleport: [String, Object],
// whether to close popup when click overlay
closeOnClickOverlay: Boolean,
// z-index
@@ -319,9 +319,9 @@ export default createComponent({
},
render() {
- const { getContainer } = this;
- if (getContainer) {
- const to = isFunction(getContainer) ? getContainer() : getContainer;
+ const { teleport } = this;
+ if (teleport) {
+ const to = isFunction(teleport) ? teleport() : teleport;
return (
{this.genOverlay()}
diff --git a/src/popup/test/index.spec.js b/src/popup/test/index.spec.js
index f570087a7..2aa3d27e5 100644
--- a/src/popup/test/index.spec.js
+++ b/src/popup/test/index.spec.js
@@ -53,7 +53,7 @@ test('get container with parent', () => {
wrapper = mount({
template: `
`,
components: {
@@ -61,16 +61,16 @@ test('get container with parent', () => {
},
data() {
return {
- getContainer: () => div1,
+ teleport: div1,
};
},
});
const popup = wrapper.find('.van-popup').element;
expect(popup.parentNode).toEqual(div1);
- wrapper.vm.getContainer = () => div2;
+ wrapper.vm.teleport = () => div2;
expect(popup.parentNode).toEqual(div2);
- wrapper.vm.getContainer = null;
+ wrapper.vm.teleport = null;
expect(popup.parentNode).toEqual(wrapper.element);
});
@@ -78,8 +78,8 @@ test('get container with selector', () => {
wrapper = mount({
template: `
`,
components: {
@@ -87,8 +87,8 @@ test('get container with selector', () => {
},
});
- const dom1 = document.querySelector('.get-container-selector-1');
- const dom2 = wrapper.vm.$el.querySelector('.get-container-selector-2');
+ const dom1 = document.querySelector('.teleport-selector-1');
+ const dom2 = wrapper.vm.$el.querySelector('.teleport-selector-2');
expect(dom1.parentNode).toEqual(document.body);
expect(dom2.parentNode).toEqual(wrapper.vm.$el);
@@ -99,7 +99,7 @@ test('render overlay', async () => {
wrapper = mount({
template: `
`,
components: {
@@ -107,7 +107,7 @@ test('render overlay', async () => {
},
data() {
return {
- getContainer: () => div,
+ teleport: () => div,
};
},
});
@@ -122,7 +122,7 @@ test('watch overlay prop', async () => {
wrapper = mount({
template: `
`,
components: {
@@ -132,7 +132,7 @@ test('watch overlay prop', async () => {
return {
show: false,
overlay: false,
- getContainer: () => div,
+ teleport: () => div,
};
},
});
@@ -158,7 +158,7 @@ test('close on click overlay', async () => {
@@ -169,7 +169,7 @@ test('close on click overlay', async () => {
data() {
return {
value: true,
- getContainer: () => div,
+ teleport: () => div,
};
},
methods: {
diff --git a/src/share-sheet/README.md b/src/share-sheet/README.md
index c54f46c16..d6e0e7ba8 100644
--- a/src/share-sheet/README.md
+++ b/src/share-sheet/README.md
@@ -123,7 +123,7 @@ export default {
| close-on-popstate | Whether to close when popstate | _boolean_ | `true` |
| close-on-click-overlay | Whether to close when click overlay | _boolean_ | `true` |
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
-| get-container | Return the mount node for ShareSheet | _string \| () => Element_ | - |
+| teleport | Return the mount node for ShareSheet | _string \| Element_ | - |
### Data Structure of Option
diff --git a/src/share-sheet/README.zh-CN.md b/src/share-sheet/README.zh-CN.md
index 1c25ca9dd..d88edc317 100644
--- a/src/share-sheet/README.zh-CN.md
+++ b/src/share-sheet/README.zh-CN.md
@@ -169,7 +169,7 @@ export default {
| close-on-popstate | 是否在页面回退时自动关闭 | _boolean_ | `true` |
| close-on-click-overlay | 是否在点击遮罩层后关闭 | _boolean_ | `true` |
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` |
-| get-container | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - |
+| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - |
### Option 数据结构
diff --git a/src/share-sheet/index.js b/src/share-sheet/index.js
index ab5c723aa..429539f5e 100644
--- a/src/share-sheet/index.js
+++ b/src/share-sheet/index.js
@@ -13,9 +13,9 @@ export default createComponent({
...popupSharedProps,
title: String,
duration: [Number, String],
+ teleport: [String, Object],
cancelText: String,
description: String,
- getContainer: [String, Function],
options: {
type: Array,
default: () => [],
@@ -141,7 +141,7 @@ export default createComponent({
duration={this.duration}
lazyRender={this.lazyRender}
lockScroll={this.lockScroll}
- getContainer={this.getContainer}
+ teleport={this.teleport}
closeOnPopstate={this.closeOnPopstate}
closeOnClickOverlay={this.closeOnClickOverlay}
safeAreaInsetBottom={this.safeAreaInsetBottom}
diff --git a/src/share-sheet/test/index.spec.js b/src/share-sheet/test/index.spec.js
index d4a3a87bd..f8a1e437a 100644
--- a/src/share-sheet/test/index.spec.js
+++ b/src/share-sheet/test/index.spec.js
@@ -89,7 +89,7 @@ test('click-overlay event', async () => {
const wrapper = mount(ShareSheet, {
propsData: {
value: true,
- getContainer: () => root,
+ teleport: root,
},
});
diff --git a/src/toast/README.md b/src/toast/README.md
index d974164d2..d9c056df3 100644
--- a/src/toast/README.md
+++ b/src/toast/README.md
@@ -154,4 +154,4 @@ Toast.resetDefaultOptions('loading');
| onOpened | Callback function after opened | _Function_ | - |
| onClose | Callback function after close | _Function_ | - |
| transition `v2.2.6` | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | _string_ | `van-fade` |
-| getContainer | Return the mount node for Toast | _string \| () => Element_ | `body` |
+| teleport | Return the mount node for Toast | _string \| Element_ | `body` |
diff --git a/src/toast/README.zh-CN.md b/src/toast/README.zh-CN.md
index 6eb067bad..633a264d2 100644
--- a/src/toast/README.zh-CN.md
+++ b/src/toast/README.zh-CN.md
@@ -167,4 +167,4 @@ Toast.resetDefaultOptions('loading');
| onOpened | 完全展示后的回调函数 | _Function_ | - |
| onClose | 关闭时的回调函数 | _Function_ | - |
| transition `v2.2.6` | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | _string_ | `van-fade` |
-| getContainer | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | `body` |
+| teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` |
diff --git a/src/toast/index.js b/src/toast/index.js
index cc9c0b49a..cbb64932c 100644
--- a/src/toast/index.js
+++ b/src/toast/index.js
@@ -11,12 +11,12 @@ const defaultOptions = {
onClose: null,
onOpened: null,
duration: 2000,
+ teleport: 'body',
iconPrefix: undefined,
position: 'middle',
transition: 'van-fade',
forbidClick: false,
loadingType: undefined,
- getContainer: 'body',
overlayStyle: null,
closeOnClick: false,
closeOnClickOverlay: false,