【发布时间】:2023-01-03 03:20:09
【问题描述】:
将我的数据组件绑定到模板后,我不断收到以下错误。任何帮助,将不胜感激。
脚本:
data() {
return {
sireDetailsData: [],
horse_show_name_prop:,
}
},
async created () {
const psireName = await this.sireName;
console.log(psireName)
try {
const response = await sireDetails.fetchHorseIndex(psireName);
this.sireDetailsData = response.data;
try {
this.horse_show_name_prop = this.sireDetailsData[0].horse_details[0].horse_show_name
} catch (error) {
this.horse_show_name_prop = undefined
}
} catch (error) {
console.error(error);
}
},
模板:
<a-col
:span="6"
:md="6"
align="middle"
style="margin-right: 0px;"
:horse_name="horse_show_name_prop"
>
<p
class="m-0 text-sm font-bold center"
style="min-width: 0px;"
v-if="horse_name !== undefined"
>
{{ horse_name }}%
</p>
<p
class="m-0 text-sm font-bold center"
style="min-width: 0px;"
v-else
>
-
</p>
<a-tag
class="ant-tag-primary font-semibold text-xs"
style="min-width: 30px;margin-right: 0px;"
>
Win %
</a-tag>
</a-col>
在进行一些实时更改后,数据就会加载进来。这让我觉得事情呈现出了乱序。
【问题讨论】:
-
您可能需要等待
fetchHorseIndex完成。见:stackoverflow.com/a/62830489/17438890 -
如果您使用 fetch 来获取数据,请展示您的数据结构,因为我们不应该猜测它。
标签: vue.js vue-component