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/
數(shù)據(jù)元素拼接方法:array.join('');默認(rèn)逗號(,)分割工猜。
React Native 實現(xiàn)物流進(jìn)度信息
https://blog.csdn.net/caihuajian235/article/details/54347388
react-native時間軸組件的使用
https://blog.csdn.net/wayne214/article/details/89337316
常用RN組件
http://www.reibang.com/p/5840ea816464
https://blog.csdn.net/s15237411727/article/details/81086126
表格組件
http://www.reibang.com/p/6ab2a96a9f1a
https://blog.csdn.net/wayne214/article/details/89337765
數(shù)組對象屬性去重:
//根據(jù) name 和 age 去重
var tmp = [{
"id": 1,
"name": "小明", //與id為2的重復(fù)
"age": "12"
},
{
"id": 2,
"name": "小明",
"age": "15", //與id為3的重復(fù)(但是因為name 已經(jīng)和id為1的重復(fù)了 ,
實際上已經(jīng)排除不會再參與 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取兩位小數(shù)不四舍五入
取兩位小數(shù)究驴,直接用toFixed(2);保留兩位小數(shù)點逛腿,但是會四舍五入。
如果不要四舍五入昂拂,并且一定要取2位小數(shù),即使是12.1這種變成12.10可以保留3小數(shù)抛猖,然后采用截取字符串的方式格侯,截取前面2位,那樣既是保留了2位小數(shù)财著,又不四舍五入联四;
注:傳參a是要截取的數(shù)值,可以是數(shù)字也可以是字符串撑教,num是要截取的小數(shù)位數(shù)
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
}