数组

43 阅读1分钟

根据id获取数组中对应的数据 const id=this.Id

const list=data.find(item=>item.Id==this.Id) 去掉数组带有引号如["1","2"],去掉后 [1,2] let newStr = arr.map(item => {

// 判断 将该项转换成数组之后不NaN, 就进行转换操作

if (!isNaN(item - 0)) {
// 使用+ - 等数学符号可以转换成Number数据类型

    return item - 0;

} else { return item; }}); 数组合并,影响原数组 this.DaysEnde=[...this.DaysEnde,...newStr]

数组去重,new Set(),用来去重数组。Array.from()方法就是将一个类数组对象或者可遍历对象转换成一个真正的数组。 const result = Array.from(new Set(this.DaysEnde))

var index = this.DaysEnde.indexOf(7);

this.DaysEnde.splice(index, 1);