如何从Vue.js中的变量名加载组件?
16lz
2021-01-22
I want to load a component from a dynamic variable name in my vue.js application.
我想从vue中的动态变量名加载组件。js应用程序。
I have the following component registered:
我注册了以下组件:
<template id="goal">
<h1>Goal:{{data.text}}</h1>
</template>
Instead of loading it like this
而不是像这样加载
<goal></goal>
I want to load from a variable name, something like this:
我想从变量名中加载,如下所示:
<{{mytemplate.type}}></{{mytemplate.type}}>
Where, of course, mytemplate.type would be, in this case equal to "goal"
在那里,当然,mytemplate。类型将是,在这种情况下等于"goal"
1 个解决方案
#1
6
Use a dynamic component like this:
使用这样的动态组件:
<component :is="myTemplate.type"></component>
更多相关文章
- iOS uiwebview无法从javascript方法加载资源
- 执行javascript作为coldfusion页面加载
- jqGrid 数据加载完事件 loadComplete 使用
- three.js学习笔记 obj模型加载问题
- 在单选按钮上选中/取消选中,加载/隐藏部分视图
- 如何使用django从静态文件加载静态文件?
- jQuery在5秒后自动加载div
- JQuery Image滑块从json加载图片
- AngularJS我在哪里可以访问加载的控制器的范围?