• react-native项目中遇到的问题


    1.react-native的Text宽度不设置时要自适应Text的文本长度

    <View style={{alignSelf:'flex-start'}}>
    <Text>sss</Text>
    </View>

    2.react-redux使用时利用ref调用子组件方法不可用报错

    如下在父组件中调用子组件的写法

    父组件

    handleShowModalAdd = () => {
    this.add.handleToggle()//handleToggle为子组件中的方法
    }
    <SystemAdd ref={(el) => this.add = el}/>
    但是当我们在子组件中使用redux的时候,由于使用connect对子组件进行了包装,会导致获取不到子组件中的方法

    下面的是使用redux后的ref使用方法

    父组件

    handleShowModalAdd = () => {
    this.add.handleToggle()   //handleToggle为子组件中的方法
    }
    <SystemAdd onRef={(ref) => this.add = ref }/>
     子组件

    componentDidMount(){
    this.props.onRef(this)   //将组件实例this传递给onRef方法
    }


    ————————————————
    原文链接:https://blog.csdn.net/chris__wang/article/details/97390279

    3.rn中绝对定位后不能点击的问题

    在rn中, 父元素采用相对定位,子元素采用绝对定位, 如果子元素的位置超出了父元素的范围,子元素只能显示,不能添加点击事件。

    
    
  • 相关阅读:
    VBA trouble
    深入浅出Automation Anywhere
    sqlserver--install/uninstall
    linux遇到的问题
    Java并发编程:线程池的使用(转载)
    java——线程
    关于项目管理工具 maven
    从xml文件取值
    jquery
    小结-9.20
  • 原文地址:https://www.cnblogs.com/xiaoleilei123/p/11983398.html
Copyright © 2020-2023  润新知