天天看點

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=;
                           }
                       });
           

注意:this.pro—-指的是:也是一個對象

attrid=attrid.substring(,attrid.length-);  
attrArr=attrid.split('|');
attrLength=self.getJsonLength(self.goods.attr_info);
substring(開始位置,結束位置)  字元串截取 
split(分隔符)                 把字元串轉化成數組
getJsonLength(數組)         得到長度