Vue 挂载和移除组件

//挂载组件
let container = document.getElementById('containerID')  //containerID要挂载在哪里          
const comp = new (Vue.extend(CompName))({ propsData: props }).$mount() //CompName组件名
container.appendChild(comp.$el) //挂载组件


//取消挂载
let container = document.getElementById('containerID')
container.removeChild(container.childNodes[0])

你可能感兴趣的:(Vue 挂载和移除组件)