1.在字符串提取数字
let str = “49-79”;
let arr = [ ];
var ret = str.replace(/[0-9](.[0-9])?/g, function(e) {
arr.push(e)
});
结果:arr = [49 , ‘ ‘ , 79 , ‘ ‘]
2.改造数据结构
将数组中的数据一个一个拿出来,由自己想要的形式组装。<br /> let len = this.price1.length<br /> for (let i = 0; i <= len; i++) {<br /> let min = this.price1[i].min<br /> let max = this.price1[i].max<br /> this.pricelist.push({<br /> 'id': i,<br /> 'name': min + '-' + max<br /> })<br /> }<br /> console.log(this.pricelist)