在一个列出的元素中,我试图实现一个v-for
循环,它应该迭代script
部分中的项。
HTML代码看起来像这样:
<li
v-for="item in icludedItems.basicPackage"
class="flex items-center space-x-3">
<!-- Icon -->
<IconsCheck />
<span>{{ item.basicPackage }}</span>
</li>
脚本部分如下所示:
data() {
return {
icludedItems: [
{
freePackage: [
this.$t('pricing.packages.free.includedUsers'),
this.$t('pricing.packages.free.includedModules'),
this.$t('pricing.packages.free.includedLocations'),
this.$t('pricing.packages.free.includedProviders'),
],
basicPackage: [
this.$t('pricing.packages.basic.includedUsers'),
this.$t('pricing.packages.basic.includedModules'),
this.$t('pricing.packages.basic.includedLocations'),
this.$t('pricing.packages.basic.includedProviders'),
],
advancedPackage: [
this.$t('pricing.packages.advanced.includedUsers'),
this.$t('pricing.packages.advanced.includedModules'),
this.$t('pricing.packages.advanced.includedLocations'),
this.$t('pricing.packages.advanced.includedProviders'),
],
premiumPackage: [
this.$t('pricing.packages.premium.includedUsers'),
this.$t('pricing.packages.premium.includedModules'),
this.$t('pricing.packages.premium.includedLocations'),
this.$t('pricing.packages.premium.includedProviders'),
],
},
],
};
},
但是,使用这种方法不会显示任何内容,也不会出现错误。
如果我从includedItems
中删除嵌套数组,它会按预期工作。
有人知道我做错了什么吗?谢谢。
1条答案
按热度按时间xxhby3vn1#
像下面的代码片段一样尝试。(
basicPackage
是icludedItems
数组中第一个对象的属性)