我是 react native 的新手,我只想顯示具有特定時間范圍的組件。這就是我到目前為止所做的
var timerange = new Date()
return(
<View>
{timerange.getHour() === 8}
<Text>display</Text>
</View>
)
所以,如果你能看到我正好在 8 點鐘方向顯示文本。我希望它精確顯示在 8 到 16。我該如何解決這個問題?
uj5u.com熱心網友回復:
只需使用行內條件,如下所示。
var current = new Date()
return (
{(current.getHours() >= 8 && current.getHours() <= 16) && <Text>It is between 8 and 16 o`clock</Text>}
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/428559.html
