mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-16 01:41:15 +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);
|
|
},
|
|
};
|