//这个是子组件
<template>
<div class=feedback>
<component :is="comps"></component>
</div>
</template>
<script>
import caseback from './caseback'
import comment from './comment'
import feedback from './feedback'
export default {
components: {caseback, comment, feedback},
props: {
type: Number //父组件根据type的值决定显示哪个组件
},
computed: {
comps() {
return ['caseback', 'comment', 'feedback'][this.type]
}
}
}
</script>复制代码
vue中:is的用法,动态显示需要的组件
最新推荐文章于 2024-08-16 19:02:09 发布