我已经通过ajax调用获取了isRegistered,因此isRegistered需要一定的时间来设置。
<View style={{ width: '48%' }}>
<Text style={style.labelStyle}>
{isRegistered ? 'Attempt' : 'Amount'}
</Text>
</View>
因此,在我看到“尝试”之前,我首先看到了“数量”(几百毫秒的时间,如此容易被人察觉)
我怎样才能避免这种情况呢?
我正在IOS模拟器(不是设备)上开发,但不知道它也会发生在真实的设备上
如果想避免这种行为,您需要在AJAX调用完成之前显示一个加载指示器等。
<View style={{ width: '48%' }}>
{ isLoading && (<View style={{ flex: 1, justifyContent: "center", alignItems: "center"><Text style={style.labelStyle}>{"Loading"}</Text></View> )}
{ !isLoading && (
<Text style={style.labelStyle}>
{ isRegistered ? 'Attempt' : 'Amount'}
</Text>
)}
</View>
您可以尝试在前一个屏幕上提前进行这个AJAX调用,以避免这种行为。