ScrollView嵌套FlatList滚动处理
https://wwd0.github.io/2018/11/06/react-native/18.ScrollView%E5%B5%8C%E5%A5%97FlatList%E6%BB%9A%E5%8A%A8%E5%A4%84%E7%90%86/
数据元素拼接方法:array.join('');默认逗号(,)分割。
React Native 实现物流进度信息
https://blog.csdn.net/caihuajian235/article/details/54347388
react-native时间轴组件的使用
https://blog.csdn.net/wayne214/article/details/89337316
常用RN组件
//www.greatytc.com/p/5840ea816464
https://blog.csdn.net/s15237411727/article/details/81086126
表格组件
//www.greatytc.com/p/6ab2a96a9f1a
https://blog.csdn.net/wayne214/article/details/89337765
数组对象属性去重:
//根据 name 和 age 去重
var tmp = [{
"id": 1,
"name": "小明", //与id为2的重复
"age": "12"
},
{
"id": 2,
"name": "小明",
"age": "15", //与id为3的重复(但是因为name 已经和id为1的重复了 ,
实际上已经排除不会再参与 age的去重)
},
{
"id": 3,
"name": "小红",
"age": "15",
},
{
"id": 4,
"name": "小张",
"age": "20",
}
]
var result = [];
var hash = {};
var hash_ = {}
for (var i = 0; i < tmp.length; i++) {
var elem = tmp[i].name;
var elem_ = tmp[i].age;
if (!hash[elem]) {
if (!hash_[elem_]) {
result.push(tmp[i]);
hash_[elem_] = true;
};
hash[elem] = true;
}
}
console.log(result)
[{
"id": 1,
"name": "小明",
"age": "12"
}, {
"id": 3,
"name": "小红",
"age": "15",
}, {
"id": 4,
"name": "小张",
"age": "20",
}]
js取两位小数不四舍五入
取两位小数,直接用toFixed(2);保留两位小数点,但是会四舍五入。
如果不要四舍五入,并且一定要取2位小数,即使是12.1这种变成12.10可以保留3小数,然后采用截取字符串的方式,截取前面2位,那样既是保留了2位小数,又不四舍五入;
注:传参a是要截取的数值,可以是数字也可以是字符串,num是要截取的小数位数
function subStringNum(a,num) {
var a_type = typeof(a);
if(a_type == "number"){
var aStr = a.toString();
var aArr = aStr.split('.');
}else if(a_type == "string"){
var aArr = a.split('.');
}
if(aArr.length > 1) {
a = aArr[0] + "." + aArr[1].substr(0, num);
}
return a
}