vue.js中的两种遍历方式(以及substring,split,getJsonLength),
分享于 点击 35943 次 点评:79
vue.js中的两种遍历方式(以及substring,split,getJsonLength),
第一种:
$.each($('.active'), function(index, item){
attrTxt+= (' ' + $(item).text());
attrid+= ($(item).attr('attrid')+'|');
});
注意:
$(‘.active’) —-指的是:class=active的对象可能为多个span标签组成的对象
第二种:
this.pro.forEach(function (item) {
if(item.goods_attr==attrid){
this.goods_num=item.product_number;
}else{
self.goods_num=0;
}
});
注意:this.pro—-指的是:也是一个对象
attrid=attrid.substring(0,attrid.length-1);
attrArr=attrid.split('|');
attrLength=self.getJsonLength(self.goods.attr_info);
substring(开始位置,结束位置) 字符串截取
split(分隔符) 把字符串转化成数组
getJsonLength(数组) 得到长度
相关文章
- 暂无相关文章
用户点评