javascript - 如何将道具从无状态功能组件传递到类组件?
问题描述
我有一个父功能组件:
function testing() {
const columns = [{ name: 'test1' },{ name: 'test2' }];
const data = [{ data: 'data1' }];
return (
<Table columns={columns} data={data} title='Test' />
)
}
调用子类组件:
class Table extends React.Component {
render() {
const columns = this.props.columns;
const data = this.props.data;
const title = this.props.title;
}
}
现在this.props
是空对象。
在这种情况下如何访问道具?
解决方案
推荐阅读
- awk - 为什么命令没有在第二行产生输出: NR % 4 == 1, NR % 4 == 3 { printf "%6d %s\n", NR, $0 }
- ssh - SSH 服务器行为
- mysql - 错误:MySQL 意外关闭。插件“反馈”已禁用
- php - WooCommerce PHP API 超时 70 秒,尽管 max_execution_time 600 秒
- r - 具有 Mantel-Haenszl p 值的 3 路表
- java - 如何使用选择排序对数据进行排序?
- sql - 不正确的语法 - With 语句
- python-3.x - 将字符串转换为浮点数:'998 CC'
- xml - 无法删除 xml 元素
- postgresql - 我想检查列并指定 row_number()