改变值:this.setState({navBartoggle:true})

设定值:

constructor(props) {
    super(props);
    this.state = {
        navBartoggle: false,     //  导航判断
    }
}

改变值:

this.setState({navBartoggle:true})

{{
                    // console.log(event.nativeEvent.contentOffset.x);//水平滚动距离
                    console.log(event.nativeEvent.contentOffset.y);//垂直滚动距离
                    if (event.nativeEvent.contentOffset.y > 200) {
                        this.setState({navBartoggle:true})
                    }else if (event.nativeEvent.contentOffset.y <= 200) {
                        this.setState({navBartoggle:false})
                    }
                }}}
                scrollEventThrottle = {20}>

判断值:

navBar() {
    if (this.state.navBartoggle === false) {
        return(
            
        )
    } else if (this.state.navBartoggle === true) {
        return(
            
        )
    }

}

你可能感兴趣的:(改变值:this.setState({navBartoggle:true}))