![](/img/trans.png)
[英]TypeError: undefined is not an object (evaluating 'table[0][3]')
[英]TypeError: undefined is not an object (evaluating 'this')
当我从放置它的位置删除我专门创建的组件菜单时,我没有收到错误,但是当我的组件在那里时我收到错误。 谢谢你的评论。
import Menu from './Navigator'
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faBars } from '@fortawesome/free-solid-svg-icons';
export default class HeaderLeft extends Component {
constructor(props){
super(props);
this.state={check:false}
}
render() {
return (<SafeAreaView><View onStartShouldSetResponderCapture={() => { this.setState({ check: !this.state.check }) }} style={styles.align}>
<FontAwesomeIcon icon={faBars} size={16} color={"#2D6A4F"} /><Menu check={this.state.check}></Menu></View></SafeAreaView>)
}
}
const styles = StyleSheet.create({
align: {
height: 60, display: 'flex', justifyContent: 'center', padding: 20
},
});```
尝试在您的代码中按照以下代码进行更改。:
在构造函数中添加以下内容:
this.handleResponderCapture = this.handleResponderCapture.bind(this)
添加以下方法:
handleResponderCapture = () => {
this.setState({
check: !this.state.check
})
}
在视图中进行如下更改
<View
onStartShouldSetResponderCapture={this.handleResponderCapture}
style={styles.align}
>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.