如何从 Vue.js 中的变量名加载组件?

2024-01-21

我想从 vue.js 应用程序中的动态变量名称加载组件。

我注册了以下组件:

<template id="goal">
  <h1>Goal:{{data.text}}</h1>
</template>

而不是像这样加载它

<goal></goal>

我想从变量名加载,如下所示:

<{{mytemplate.type}}></{{mytemplate.type}}>

当然,在本例中,mytemplate.type 等于“目标”


Use a 动态组件 https://vuejs.org/guide/essentials/component-basics.html#dynamic-components像这样:

<component :is="myTemplate.type"></component>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从 Vue.js 中的变量名加载组件? 的相关文章

随机推荐