vuejs 使用动态模板及其相关数据处理组件的更好方法

vuejs better way to address component with dynamic template and its relative data?

本文关键字:数据处理 组件 方法 更好 动态 vuejs      更新时间:2023-09-26

我有以下问题/要求,如果有人有好主意,请发帖讨论它用于动态模板和数据使用组件的动态渲染场景如下:

根 vue 实例从后端获取数据,例如返回以下数据:

[
{
    /* this section will be fed to a component */
    type: 'FirstSub',
    templatestr: '<div> <more-vue-customized-component itsdata="xxx"></more-vue-customized-component>  </div>',
    data: [
        datafordynamicComponent: xxxx
    ]
},
...
{
    /* this section will be fed to a component */
    type: 'lastSub',
    templatestr: '<p> <more-vue-customized-component itsdata="xxx"></more-vue-customized-component>  </p>',
    data: [
        datafordynamicComponent: xxxx
    ]
}

]2. 我们可以使用哪种结构/架构来使用上述数据渲染为以下构图?

<root>
<FirstSub></FirstSub>
...
<lastSub></lastSub>
</root>

你能使用异步组件吗?

https://vuejs.org/guide/components.html#Async-Components