typescript - SearchParams 的 If Else 语句 [React Native]
问题描述
我是 React Native 的新手,我正在为 React Native 使用 typescript。目前,我很难为搜索功能做 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>
)}
推荐阅读
- php - 通过 websocket 服务器从 http 访问的 PHP 发送数据
- kendo-ui - 创建新记录在 Jquery Kendo 子网格中不起作用
- javascript -
- javascript - 在 javascript 中检查 xsi:null: true
- ruby-on-rails - 在 Rails 应用程序的公共文件夹中访问“环境变量”
- javascript - require() 后如何更改所需的连接
- c# - 带旋转的 2D 完美射弹反射
- java - 如何检查日期格式是否正确
- kotlin - 为什么 Kotlin 允许编写不带参数的 main 函数?
- apache-kafka - 将 Kafka 设置从单节点集群迁移到多节点集群