您的位置:首页 > 产品设计 > UI/UE

vue.js中的两种遍历方式(以及substring,split,getJsonLength)

2017-09-09 15:45 405 查看
第一种:

$.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(数组)         得到长度
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐