【发布时间】:2019-06-18 06:07:09
【问题描述】:
我有一个单页应用程序,我试图根据数组(blockCount)中存在的组件来导入和呈现组件。我在所述数组中存储了几个字符串(组件名称)。
Vue:
computed: {
componentInstance () {
for(var i = 0; i < this.blockCount.length; i++){
return () => import(`@/components/${this.blockCount[i]}`)
}
}
},
Html:
<component v-for="component in blockCount" :is="componentInstance" />
所以我遇到的问题是函数在 item[0] 处停止并且只是迭代该项目。而且我不太确定如何以动态方式迭代此函数。
【问题讨论】:
标签: vue.js components