-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Description
问题描述
微信小程序父组件向子组件传递函数,执行了但是还是报错
复现步骤
1.首先我先封装了一些tabBar组件,代码如下
import Taro from '@tarojs/taro-h5';
import { AtTabBar } from 'taro-ui';
export default class Index extends Taro.Component {
constructor() {
super(...arguments);
this.state = {
current: 0
};
}
handleClick(value) {
this.setState({
current: value
});
console.log(this.props);
this.props.onCurrentPage(value);
}
render() {
return <AtTabBar
selectedColor="#212121"
color="#BDBDBD"
fixed={this.props.fixed}
tabList={this.props.tabList}
onClick={this.handleClick.bind(this)}
current={this.state.current} />;
}
}
2.然后我在某个页面使用了这个组件
// 这是父组件的函数
currentPage(value) {
this.setState({
currentPageShow: value
});
}
// 这个是调用这个组件
<TabBar tabList={tabList} fixed={fixed} onCurrentPage={this.currentPage.bind(this)} />
期望行为
微信小程序和h5一样能够完美运行
- 报错平台 [weapp]
补充信息
Metadata
Metadata
Assignees
Labels
No labels