Using string literals in ref att

作者: JsLin_ | 来源:发表于2018-07-26 20:26 被阅读12次

eslint报错问题

<TextInput
              style={styles.textInputStyle}
              underlineColorAndroid="transparent"
              keyboardType="numeric"
              maxLength={11}
              placeholder="请输入收到的验证码"
              placeholderTextColor="#cccccc"
              onChangeText={text => this.setState({ msgCode: text })}
              ref="MsgCode"
            />

正确格式为下面 用到refs属性时,比如:直接this.MsgCode.blur()

   <TextInput
              style={styles.textInputStyle}
              underlineColorAndroid="transparent"
              keyboardType="numeric"
              maxLength={11}
              placeholder="请输入收到的验证码"
              placeholderTextColor="#cccccc"
              onChangeText={text => this.setState({ msgCode: text })}
              ref={(c) => { this.MsgCode = c; }}
            />

相关文章

网友评论

    本文标题:Using string literals in ref att

    本文链接:https://www.haomeiwen.com/subject/fdovmftx.html