<template>
<div>
<div v-for="item in list" :key="item.componentName">
<component :is="item.componentName" v-bind="item.props">
{
{ item.props.children }}
</component>
</div>
</div>
</template>
<script setup lang="ts">
const list = [
{
componentName: 'el-button',
props: {
type: 'primary',
children: '登录'
}
},
{
componentName: 'el-button',
props: {
type: 'warning',
children: '注册'
}
}
]
</script>
<style scoped></style>
vue3利用component组件实现 string转为组件渲染
猜你喜欢
转载自blog.csdn.net/weixin_35958891/article/details/130907352
今日推荐
周排行