ant-design-vue/components/_util/portalDirective.js
2020-05-13 18:36:53 +08:00

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);
},
};