【发布时间】:2020-10-13 22:13:10
【问题描述】:
我们能否在 react 的功能组件中使用 props,如果可以,如何使用。 我正在尝试做
console.log(this.props)
在功能组件中的返回函数上方,但它一直给我错误。
【问题讨论】:
-
嗨@Salman Ahmed,如果它是基于类的组件,则使用
this访问props,否则直接访问 -
docs 始终是开始学习的好地方。
标签: reactjs react-props react-component react-functional-component react-class-based-component