export default class Index extends Component { // 接受新props更新,注意设置的参数是nextProps componentWillReceiveProps(nextProps) { this.setState({ isShow: nextProps.isShow }); } constructor() { super(...arguments) this.state = { isShow: false, } } render() { const { isShow } = this.state; return ( <View className={isShow ? "show" : "hide"}> </View> ) } }