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>

更多相关文章

  1. iOS uiwebview无法从javascript方法加载资源
  2. 执行javascript作为coldfusion页面加载
  3. jqGrid 数据加载完事件 loadComplete 使用
  4. three.js学习笔记 obj模型加载问题
  5. 在单选按钮上选中/取消选中,加载/隐藏部分视图
  6. 如何使用django从静态文件加载静态文件?
  7. jQuery在5秒后自动加载div
  8. JQuery Image滑块从json加载图片
  9. AngularJS我在哪里可以访问加载的控制器的范围?

随机推荐

  1. jquery 监控文本框键盘事件(回车事件),附常
  2. 使用javascript进行内容占位符问题的第二
  3. 围绕一个带有jQuery旋钮的输入元素。
  4. 如何在java脚本中获取节点内部文本?
  5. jQuery实现checkbox的全选和反选
  6. jquery 循环添加事件
  7. 将ajax GET请求发送到ASP .NET Web API
  8. 如何在流体宽度旋转木马中的页面之间创建
  9. 5秒后删除新的div
  10. jQuery中的ajax服务端返回方式