vue.js - Tabview 未在 nativescript-vue 的第一个选项卡中显示数据
问题描述
我在我的组件中放置了一个带有 2 个选项卡的 Tabview。首先,我从 API 加载一些数据并用数据呈现 ListView。在另一个选项卡中,我显示了一些其他数据。
首次显示组件时,API 中的数据未显示,我有选项卡按选项卡 2,然后按选项卡 1,然后显示数据。
<template>
<Page class="page">
<TabView :selectedIndex="selectedIndex"
@selectedIndexChange="indexChange">
<TabViewItem title="Tab 1">
<StackLayout orientation="vertical">
<ListView height="90%" class="list-group"
for="item in allCategories">
<v-template>
<StackLayout class="list-group-item"
orientation="horizontal">
<Image :src="item.imageURL"
stretch="aspectFill" class="categoryImage"
width="75" height="75">
</Image>
<Label class="categoryText"
:text="item.element.groupText"/>
</StackLayout>
</v-template>
</ListView>
</StackLayout>
</TabViewItem>
<TabViewItem title="Tab 2">
<Label text="Content for Tab 2" />
</TabViewItem>
</TabView>
</Page>
</template>
created: function () {"url").then(result => {
result.data.forEach(element => {
var imageURL = element.image.imageURL;
this.allCategories.push({element, imageURL })
});
}, error => {
console.log(error);
});
},
我希望在组件首次显示时显示数据,因为选项卡 1 被标记为显示选项卡。有任何想法吗?
这是操场上的一个例子:https ://play.nativescript.org/?template=play-vue&id=9Fk7AS&v=10
解决方案
答案在我为 github 中的存储库提交的问题中:https ://github.com/nativescript-vue/nativescript-vue/issues/515
只是改变:
<TabView :selectedIndex="selectedIndex" @selectedIndexChange="indexChange">
到:
<TabView>
推荐阅读
- java - 如何处理使用复制相同数据的相同ID动态实现的edittext?
- python - Python asyncio:关闭套接字并释放等待 sock_read()
- unit-testing - 如何使用@testing-library/react-native 在 React Native 中监视 TouchableNativeFeedback onPress?
- sql-server-2008 - 编写查询以匹配具有复杂匹配条件的表之间的记录时出现问题
- html - 如何删除按钮上的两个图像之一?
- python - 如何将 spacy doc 转换为嵌套的令牌列表
- ffmpeg - 如何在FFMpeg中连接两个或多个具有相同宽度和不同高度的视频并保持相同的纵横比?
- python - Sympy:使用 sympify 将自定义函数减少为字符串?
- c# - 如何测量函数的物理内存使用量?
- curl - 403-尝试使用 curl 登录网站时出现 CSRF 错误