vue中动态添加组件
效果:
代码:
<template><div><divv-for="(item,index)inlst"><h5>{{item.id}}</h5><leave></leave></div><hr><button@click="create">创建</button></div></template><script>importleavefrom'./components/leave.vue'exportdefault{name:'createComponent',data(){return{lst:[{"id":"1"}],num:1}},components:{leave},methods:{create(){this.num++;this.lst.unshift({"id":this.num});}}}</script><stylescoped></style>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。