vue.js - 迭代一个组件数组(并挂载它们)
问题描述
如何安装在数组中“声明”的组件?
例子:
<template>
<div v-for="component in COMPONENTS_ARRAY" :key="component">
<!-- I want it to iterate through COMPONENTS_ARRAY and mount them here -->
<!-- Not working. No errors but doesn't render -->
{{ component }}
</div>
</template>
<script>
import AboutPage from './about-page.vue'
import SomePopup from './some-popup.vue'
const COMPONENTS_ARRAY = [
'<AboutPage :title="title" />',
'<AboutPage title="This is a Title" />',
'<SomePopup description="This is a description" />',
'<SomePopup header-color="red" />'
]
export default {
props: {
title: {
type: String
}
},
data () {
return {
COMPONENTS_ARRAY
}
},
components: {
AboutPage,
SomePopup
}
}
</script>
所以基于上面的例子,我想要挂载 4 个组件实例。
我有什么办法可以做到这一点??
解决方案
推荐阅读
- vba - vba 应用程序定义或对象定义的错误(工作的代码停止工作)
- discord.js - (discord js 反垃圾邮件)如何制作白名单频道命令?
- android-studio - Android Studio 代码折叠限制为 80 个字符 - 设置不起作用 (MacOs Big Sur)
- lua - 如何将打印件与 roblox 中的脚本连接起来?
- apache-spark - 无法捕获 Pyspark UDF 异常
- firebase - Flutter中的求和问题不起作用,如何在导航栏中显示总收入?
- python-3.x - 如何在 Python 中从 Arduino 读取串行数据时减少延迟?
- tailwind-css - Tailwindcss 使用悬停在 group-hover
- android - Spinner 导致我的应用在 android studio 中崩溃
- mongodb - 通过 GraphQL 合并或“引用”和对象到另一个?