Typescript SearchParams[React Native]的If-Else语句
我是React-Native新手,我正在使用React-Native的typescript。目前,我很难对搜索函数执行if-else语句。下面是搜索函数的if-else语句的代码Typescript SearchParams[React Native]的If-Else语句,typescript,react-native,searchbar,Typescript,React Native,Searchbar,我是React-Native新手,我正在使用React-Native的typescript。目前,我很难对搜索函数执行if-else语句。下面是搜索函数的if-else语句的代码 {searchParams !== "" ( <View> <Text>Sorry, error occur</Text> </View> ) : ( <View> <Text>Success!</Text&g
{searchParams !== "" (
<View>
<Text>Sorry, error occur</Text>
</View>
) : (
<View>
<Text>Success!</Text>
</View>
)}
{searchParams!==“”(
抱歉,发生错误
) : (
成功
)}
{searchParams!==“”(
抱歉,发生错误
) : (
成功
)}
您缺少一个问号:{searchParams!==“”?
抱歉,发生错误
:
成功
}
这里是链接
您的错误是什么?非常感谢。在我添加问号后,我的if-else语句用于搜索功能的工作非常感谢。添加问号后,搜索函数的if-else语句起作用
{searchParams !== "" ? (
<View>
<Text>Sorry, error occur</Text>
</View>
) : (
<View>
<Text>Success!</Text>
</View>
)}
{searchParams !== "" ?
<View>
<Text>Sorry, error occur</Text>
</View>
:
<View>
<Text>Success!</Text>
</View>
}