export default {
name: COMPONENT_NAME,
props: {
// 是否显示
visible: {
type: Boolean,
default: false
},
// 标题
title: {
type: String,
default: 'Modal'
}
},
mounted() {
console.log('mounted', this);
console.log('document.body.appendChild(this.$el)', this.$el);
document.body.appendChild(this.$el);
},
destroyed() {
if (this.$el && this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el);
}
},
methods: {
closeModal() {
this.$emit('close');
}
}
};
在vue中封装modal弹出框,见到了如下代码,就比较好奇$el到底指向的是什么
经过验证:指向的正是本组件的elemnt