【发布时间】:2019-01-19 23:47:39
【问题描述】:
我正在尝试显示文本数组/对象的值,但我得到一个输出,试图显示数组/对象中每个名称的段落。
链接到当前结果:current result
我是 vue.js 的新手,所以欢迎任何提示!
<template>
<div class="education center">
<div v-if="object.timelines != null">
<template v-for="(time,index) in object.timelines">
<p :key="index">{{ time.schoolyear }}</p>
<div :key="index" v-bind="time" v-for="(text,index) in time.text">
<p :key="text">Degree: {{ text.degree }}</p>
<p>Institution: {{ text.institution }}</p>
<p>Where: {{text.where}}</p>
</div>
</template>
</div>
</div>
</template>
<script>
export default {
el: ".education",
data: function() {
return {
object: {
timelines: [
{
schoolyear: "2016 - 2017",
text: [
{ degree: "Applied Computer Science" },
{ institution: "Thomas More University of Applied Science" },
{ where: "Belgium, Geel" }
]
},
{
schoolyear: "2018 - 2019",
text: [
{ degree: "Business IT" },
{ institution: "HAMK University of Applied Science" },
{ where: "Finland, Hämeenlinna" }
]
}
]
}
};
}
};
</script>
我只想为 schoolyear="2016 - 2017" 显示一次 text.degree
【问题讨论】:
-
试试
<p :key="text" v-if="time.schoolyear=='2016 - 2017'">Degree: {{ text.degree }}</p> -
很遗憾,这并不能解决问题。如果您使用大型数组,这似乎也是一项巨大的工作......
-
请重新表述您的问题,因为我误解了您
-
你能控制对象/时间线吗?
-
我看到你的文本对象应该和我做的一样here