【发布时间】:2018-09-27 09:33:11
【问题描述】:
在我的数据对象中
items: [
{ name: "Breakfast", comp: "breakfastItems" },
{ name: "Lunch", comp: "lunchItems" },
{ name: "Dinner", comp: "dinnerItems" },
{ name: "Dessert", comp: "desertItems" }
]
其中 comp 是计算属性。 在我的组件模板中,我想使用 for 循环来实现这样的目标。
<span v-for="n in items">
{{n.comp}}
</span>
这不起作用,因为我需要在渲染时添加 {{}}。我该怎么做?
【问题讨论】:
-
你需要这样的东西吗?
{{ '{' + n.comp + '}' }}