把vue组件添加到body下

时间:2019-05-25 17:38:15   收藏:0   阅读:1732

写了个batman-active-panel组件

为了减少父级html的影响,需要把组件的$el放在body下

在mounted放法中写:

 

this.$nextTick(() => {
      const body = document.querySelector("body");
      if (body.append) {
        body.append(this.$el);
      } else {
        body.appendChild(this.$el);
      }
    });

  

其中做了兼容IE11

 

原文:https://www.cnblogs.com/saving/p/10923166.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!