uniapp 常用、增删改查、计算、数据转换、小数点后保留等操作
数据转换
JSON.stringify(data)
JSON.parse(data)
parseInt(1.6);
Math.floor(1.6);
Math.ceil(1.6);
Math.round(1.6);
num (value) {
let number = parseFloat(value).toFixed(2)
return number
}
num (value) {
let tempVal = parseFloat(value).toFixed(3)
let realVal = tempVal.substring(0, tempVal.length - 1)
return realVal
}
删除数组元素
let arr = [1, 2, 3, 4, 5];
arr.splice(1, 1);
console.log(arr);
let arr = [1, 2, 3, 4, 5];
arr = arr.filter(function(item, index){
return index !== 2;
});
console.log(arr);
let arr = [1, 2, 3, 4, 5];
let last = arr.pop();
console.log(arr);
console.log(last);
let arr = [1, 2, 3, 4, 5];
let first = arr.shift();
console.log(arr);
console.log(first);