Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
465 views
in Technique[技术] by (71.8m points)

Vue通过组件的type类型封装动态组件

我需要遍历el-checkboxel-radio

通常场景场景是

<el-checkbox v-fo="item in 2"></el-checkbox>
这时候页面出现了2个
<el-checkbox>1<el-checkbox>
<el-checkbox>2<el-checkbox>

实际上期望的是
<el-checkbox>1<el-checkbox>
<el-radio @click="func">2<el-radio>

就是将多个不同的组件遍历到页面上渲染 而不是单独遍历一个组件出来,而且我可能el-radio还绑定了事件

除了楼下的is 通过rander函数也能实现,有大神出过或看过比较好的文章吗


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

用vue动态组件就能满足吧,

<component v-bind:is="currentTabComponent"></component>

遍历时,传入不同组件名,


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...