react-native中TextInput在ios平台下不能输入中文
2024-09-01 18:51:42
react-native 0.55.4
版本,发现TextInput 在iOS平台上无法输入中文的问题。
1. github上相关资料
import React, {Component} from 'react';
import {Platform, TextInput} from 'react-native';
class MyTextInput extends Component {
shouldComponentUpdate(nextProps){
return Platform.OS !== 'ios' || this.props.value === nextProps.value;
}
render() {
return <TextInput {...this.props} />;
}
};
export default MyTextInput;
代码加入到项目中后,试运行了下发现果然是可以的,以为至此不能输入中文的bug,应该是破掉了。
2.需要满足defultValue和value属性
项目中由于很多都地方使用了defultValue和value属性,所以在详细的测试中发现,以上封装只能满足于value属性的情况下没问题的,那么还需要满足defultValue属性了。
以下为封装后的代码:
import React, {Component} from 'react';
import {Platform, TextInput} from 'react-native';
class MyTextInput extends Component {
shouldComponentUpdate(nextProps) {
const { value, defaultValue } = this.props;
return Platform.OS !== 'ios'
|| (value === nextProps.value && !nextProps.defaultValue)
|| (defaultValue === nextProps.defaultValue && !nextProps.value);
}
render() {
return <TextInput {...this.props} />;
}
};
export default MyTextInput;
另: native-base中Input,Textarea等组件在ios平台下不能输入中文
最新文章
- 《LoadRunner12七天速成宝典》签售会2016-12-17北京
- 【翻译svg教程 】svg 的坐标系统
- ACM/ICPC 之 最短路-Floyd+SPFA(BFS)+DP(ZOJ1232)
- EBS R12.2 创建应用层的启动和关闭脚本
- input两种默认显示文字方式
- 商务通简单弹窗样式 V1.0
- 转: Firefox 浏览器对 TABLE 中绝对定位元素包含块的判定有错误
- Node.js 博客实例(五)编辑与删除功能
- 重点+超详细:ajax和json及案例
- [数据挖掘] - 聚类算法:K-means算法理解及SparkCore实现
- Tomcat+Eclipse乱码问题解决方法
- npm 常用命令详解
- [Java第一课]环境变量的配置以及eclipse一些常用快捷键
- 一、Java 23 种设计模式简介
- 团队项目-课程MS需求分析心得
- React文档(二十二)context
- double 四舍五入保留一定的位数
- HTML5结构标签
- NOI-1.3-11-计算浮点数相除的余数
- git 修改已提交的注释