【发布时间】:2021-02-15 21:59:24
【问题描述】:
我有一个奇怪的错误,在模拟器中可以看到定价并且工作正常,但是在移动设备上检查时,它没有显示,虽然它在那里但只是没有显示。我尝试过更改字体颜色、添加 if 条件等,但都不起作用。
另外,在注意到并解决这个错误时,我发现当数字在小数点后很大时,它确实会显示出来。(屏幕截图)但当它更小时不会显示。
Mobile Screenshot price visible
Mobile Screenshot price not visible
用于在价格中添加逗号的函数。
export function numberWithCommas(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
用于在末尾预览总计的代码。
return (
<View style={{ flex: 1 }}>
<Tab.Navigator>
<Tab.Screen name="One-Time Cart" component={OneTimeCart} />
<Tab.Screen name="Subscription Cart" component={SubscriptionCart} />
</Tab.Navigator>
<View style={styles.cartTotal}>
<View style={styles.cartTotalSubView}>
<Text style={styles.cartAllText}>One Time Cart:</Text>
<Text style={[styles.price, styles.cartAllText]}>₹ {numberWithCommas(grandTotal[0])}</Text>
</View>
<View style={styles.cartTotalSubView}>
<Text style={styles.cartAllText}>SubScription Cart:</Text>
<Text style={[styles.price, styles.cartAllText]}>₹ {numberWithCommas(grandTotal[1])}</Text>
</View>
<View style={styles.cartTotalSubView}>
<Text style={styles.cartAllText}>Total:</Text>
<Text style={[styles.price, styles.cartAllText]}>₹ {numberWithCommas(grandTotal[0] + grandTotal[1])}</Text>
</View>
</View>
<View>
<Button style={styles.checkoutButton} onPress={() => navigation.navigate("Checkout")}><Text style={styles.buttonText}>CHECKOUT</Text></Button>
</View>
</View>
)
【问题讨论】:
标签: react-native react-redux jsx custom-font