一. react native 截取/替换字符串, 字符串转数组, 字符串中空格/字母/数字的个数
1. 截取字符串
var str = 'abcdefg';
// 以2为起点,截取3个字符
var resultStr = str.substr(2,3);
// resultStr的结果为 'cde'
2. 判断是否包含某个字符串
var a = 'cukiy.com';
// 判断字符串a中是否包含 'com' 如果包含就返回所在的index 不包含返回-1
if (a.indexOf('com') == -1) {
alert('不包含')
} else {
// 包含,所在的位置 a.indexOf('com') = 6
alert(a.indexOf('com'))
}
3. 替换字符串
var a = 'cukiy.com';
// replace只会替换第一个c
a.replace('c','西');
alert(a); // 打印结果 西ukiy.com
// 如果想要替换所有指定的字符串,可以用while循环
while(a.indexOf('c') >= 0) { // 判断a字符串中是否包含'c',如果包含就替换掉,然后继续判断是否包含C,包含就替换继续判断,不包含就结束循环
a = a.replace('c','西');
}
alert(a); // 打印结果 西ukiy.西om
4. 字符串转数组
var test = 'aaa,bbb,ccc,ddd';
// 以 , 分割
var strArray =test.split(',')
// strArray的结果为['aaa','bbb','ccc','ddd']
5. 数组转字符串
var arr = ['aaa','bob','ccc'];
// 以 - 拼接
var str = dateArr.join('-');
// str的结果为 'aaa-bbb-ccc'
6. 字符串中数字的个数
var numCnt = str.replace(/\D/g, '').length;
7.字符串中汉字的个数
var count = str.match(/[\u4E00-\u9FA5]/g).length;
8. 字符串中大小写字母的个数
var alphaNum = str.replace(/[^a-zA-Z]/g, '').length;
9. 字符串中空格的个数
var spaceCnt = str.replace(/\S/g, '').length;
二. es6语法
知乎:https://www.zhihu.com/question/50658324?sort=created.
历史版本:http://www.ecma-international.org/publications/standards/Ecma-262-arch.htm
三. React Native 开源组建和开源App
https://blog.csdn.net/whatofit/article/details/51843287
Ignite生成项目详解:https://www.jianshu.com/p/cb8dc64e650a
IGNITE生成项目分解(1):https://www.jianshu.com/p/1b0cb5b32049
React-Native配合ignite 开发文档:https://www.jianshu.com/p/efc9a00b843a
React Native decoide IDE:https://www.decoide.org/docs/components
React Native Ignite:https://github.com/infinitered/ignite-ir-boilerplate
四. Redux
https://github.com/xgrommx/awesome-redux
http://cn.redux.js.org//docs/introduction/Examples.html#todomvc
https://www.kancloud.cn/dingyiming/redux/139283
https://www.kancloud.cn/search?q=redux
https://www.kancloud.cn/kancloud/redux_tutorial/216733
http://www.css88.com/react/docs/typechecking-with-proptypes.html
http://blog.codingplayboy.com/2017/10/31/react-native-app/#saga-3
https://github.com/codingplayboy/reactjs/tree/master/react-native/fuc
https://github.com/luckcoding/react-native-boilerplate
http://react-china.org/t/reactnative/3486
https://github.com/react-guide
https://redux-saga-in-chinese.js.org/docs/basics/UsingSagaHelpers.html
https://www.cnblogs.com/johnxc/p/6800703.html
网友评论