React函数组件能否使用props与父组件通信?
问题描述:
举个栗子?:
如果父子组件都为Symbol(react.element)
,通常可以直接用props进行父子通信
// father.js handleChange = data => { // ... } <Children onChange={this.handleChange}/> // children.js export default class Children extends React.Component { handleIptChange = e => { this.props.onChange({value: e.target.value}) } render(){ return <input onChange={this.handleIptChange} /> } }
请问如果children.js里面为函数组件,如何利用props和父级通信?
// children.js export default function Children(props = {}) { return <input onChange={handleIptChange} /> } function handleIptChange(){ // ... }
<el-col :span="6"> <el-form-item label="价格" class="block" prop="price"> <el- ...