240 发简信
IP属地:西藏
  • /**
    * 设置悬浮控件的透明度
    */
    changeFilterModalOpacity(scrollState) {
    let top = this.top;
    let opacity = (scrollState === 0 || scrollState === 2) ? top : 1;
    this.refs.float_filter_modal.setNativeProps({
    opacity: opacity
    })
    }

    componentWillUpdate() {
    // 这样就不会导致Header在上滑的过程中一直向上滑动了
    const height = this.state.headerHeight;
    this.top = this.state.headerTop.interpolate({
    inputRange: [0, height / 8, height / 6, height / 4, height / 2, height],
    outputRange: [1, 0.8, 0.6, 0.4, 0.2, 0]
    });
    }
    这样操作会报一个错误,如果将opacity this.top修改为0 就不报错了,请问是怎么解决的

    react-native setNativeProps 详解

    在React-Native里面,如果要改变组件的样式可以通过state 或者 props来做到。但有些时候由于性能瓶颈,不得不放弃通过触发render的方式来改样式,而是通过...