vue中使用数组方法push
具体写法可以有两种:第一种:在函数内部声明变量,var company = [], hushu = [], bili = [];console.log("company",company,"hushu",hushu,"bili",bili);for(var i = 0 ;i<arr.length;i++){company.push(arr[i].company);hushu.push(arr
·
具体写法可以有两种:
第一种:在函数内部声明变量,
var company = [], hushu = [], bili = [];
console.log("company",company,"hushu",hushu,"bili",bili);
for(var i = 0 ;i<arr.length;i++){
company.push(arr[i].company);
hushu.push(arr[i].hushu);
bili.push(arr[i].dianscale);
}
console.log("company1",company,"hushu1",hushu,"bili1",bili);
第二种:在data中先声明在接收。
data(){
return{
companyArr:[],
hushuArr:[],
biliArr:[]
}
},
//方法里面的部分
for(var i = 0 ;i<arr.length;i++){
this.companyArr.push(arr[i].company);
this.hushuArr.push(arr[i].hushu);
this.biliArr.push(arr[i].dianscale);
}
console.log("companyArr",this.companyArr,"hushuArr",this.hushuArr,"biliArr",this.biliArr);
更多推荐
已为社区贡献1条内容
所有评论(0)