zoukankan      html  css  js  c++  java
  • 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中, 父元素采用相对定位,子元素采用绝对定位, 如果子元素的位置超出了父元素的范围,子元素只能显示,不能添加点击事件。

    
    
  • 相关阅读:
    论苹果笔记本电脑在学校里如何联网
    年初
    2016年看书总结
    Say goodbye to my photos&videos
    After the exam
    Warm myself by my hand
    好好努力吧少年
    明晃晃的月亮真好看
    在SQL service或Oracle中将数字转换成有千位符号
    Oracle 计算两个日期间隔的天数、月数和年数
  • 原文地址:https://www.cnblogs.com/xiaoleilei123/p/11983398.html
Copyright © 2011-2022 走看看