Прежде всего, спасибо Boussadjra Brahim за предоставление кодового пера, который решил мою проблему.
Сначала я перефразирую вопрос, а затем скопирую решение.
Вопрос : Я хочу распечатать значения из массива внутри объекта javascript.В моем <div>
теге в настоящее время печатается попытка распечатать text.institution
для каждого элемента в массиве text
.
, в результате чего vue.js пытается показать <p>Institution: {{ text.institution }}</p>
для степень , учреждение и , где .Вывод в браузере:
<p>Degree:</p>
<p>Institution: Thomas More University of Applied Science"</p>
<p>Where:</p>
для text.where
это изменится на
<p>Degree:</p>
<p>Institution:</p>
<p>Where: Belgium, Geel</p>
Ответ : Еще раз огромное спасибо Буссаджра Брахим для показа решения.
/* eslint-disable vue/require-v-for-key */
<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" :set="text = time.text">
<p>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(){
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>
Я изменил текстовый массив с квадратных скобок на фигурные скобки и вместо v-for=
я изменил на :set=
.