-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
问题描述
父组件向子组件传递函数,父组件不执行
### 父组件
import Taro, { Component } from '@tarojs/taro'
import { View, Image, Picker,Text } from '@tarojs/components';
import PageOne from './PageOne'
export default class Consulations extends Component{
constructor(props) {
super(props);
this.state = {
};
}
onHandleFilpPage(){
console.log("flip");
this.setState({
show:true
})
}
render() {
const {
petSelect,
petInfo
} = this.state;
console.log(this.props)
return (
<View className='consulations'>
<Image src={bg} class="bg"></Image>
<View className='picker'>
<Picker range={petInfo} rangeKey="name" onChange={this.onChange}>
<Text className='pet-name'>{petSelect}</Text>
</Picker>
</View>
<PageOne onClick={this.onHandleFilpPage.bind(this)} />
</View>
);}
### 子组件
import Taro, { Component } from '@tarojs/taro'
import { View, Picker,Text,Label,Input,Switch,Button } from '@tarojs/components';
import './index.less';
export default class PageOne extends Component{
constructor(props) {
super(props);
this.state = {
};
}
onClickHandler = () => {
console.log('onClickHandler');
this.props.onHandleFilpPage()
}
render() {
return (
<View>
<Text>hello</Text>
<Button onClick={this.onClickHandler}>hello</Button>
</View>
)}
}
期望行为
[父组件时间可以触发]
系统信息
- 操作系统: [MacOS 10.13.5 (]
- Taro 版本 [v0.0.73]
- Node.js 版本 [v10.10.0]
- 报错平台 [weapp]
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested