react-native - 为什么显示红色偶数代码是正确的?
问题描述
我正在开发一个反应原生应用程序。我正在为我的工作使用 Visual Studio Code。为什么我的代码中出现红色警报。
当我将鼠标悬停在它上面时,我得到
"[ts] Property 'loading' does not exist on type 'Readonly<{ children?: ReactNode; }> & Readonly<{}>'.
any"
我认为我的代码没有任何问题,但它仍然显示为红色。谁能告诉我这是什么问题。
解决方案
您必须在道具中声明您的加载。这是一个小例子:
type BooksTableProps = {
readonly data: Array<data>;
readonly pagination: Pagination;
readonly loading: boolean;
readonly error: string; // or whatever
actions here
}
在您的渲染方法中使用加载:
render() {
const {
loading,
pagination,
data,
} = this.props;
return (
<div>
<Table
columns={this.columns}
dataSource={data}
loading={loading}
pagination={pagination}
onChange={this.handleTableChange}
/>
</div>
)
}
推荐阅读
- plsql - PLS-00201 PL/SQL 中的流水线函数错误
- mysql - 如何解决 SpringBoot 应用程序中的 401 错误?
- php - 检查用户是否在会话中具有角色(PHP)
- visual-studio-code - 将文件保存在缓存中的VSCode /关闭后防止擦除
- web - 我想获取 Web 应用程序中使用的警报消息列表以手动测试它。如何得到它?有什么办法请提供
- flutter - 为什么我在上传颤振项目时遇到这些错误
- dart - 抛出和返回 Future.error 之间的区别
- flutter - Flutter:如何在启用 PanAndZoomBehaviour 的同时启用同步融合图表的滚动?
- php - 如何从 json 格式 wordpress 中获取值
- javascript - 预选的分页行在 Saleforce LWC 的数据表中不起作用