mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-15 17:31:43 +08:00
25 lines
610 B
JavaScript
25 lines
610 B
JavaScript
|
export function antPortal(Vue) {
|
||
|
return Vue.directive('ant-portal', {
|
||
|
inserted(el, binding) {
|
||
|
const { value } = binding;
|
||
|
const parentNode = typeof value === 'function' ? value(el) : value;
|
||
|
if (parentNode !== el.parentNode) {
|
||
|
parentNode.appendChild(el);
|
||
|
}
|
||
|
},
|
||
|
componentUpdated(el, binding) {
|
||
|
const { value } = binding;
|
||
|
const parentNode = typeof value === 'function' ? value(el) : value;
|
||
|
if (parentNode !== el.parentNode) {
|
||
|
parentNode.appendChild(el);
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export default {
|
||
|
install: Vue => {
|
||
|
antPortal(Vue);
|
||
|
},
|
||
|
};
|