CALSS="RADIO CHECKED";
if( typeof item.checked=='undifind' ){}
v-for = "(item,index) of List"
让vue全局注册去监听一个完全不存在的变量
Vue.set(item,"checked",true);
局部变量
this.$set()
if(typeof item.checked == 'undeifind'){
Vue.set(item,"checked",true);
}else{
item.checked = !item.checked;
}
quanxuan
checkAll:function(){
this.checkAllFlag = !this.checkAllFlag;
下列作用域不同 var _this=this
1. first
if(this.checkAllFlag){
this.productList.forEach(function (value,index){ //使用forEach 第一个是值第二个是序号
if(typeof item.checked=='undefined'){
_this.$set(item,"checked",this.checkAllFlag);
}else{
item.checked = _this.checkAllFlag
}
})
}
}
calcTotalPrice: function(){ //计算总金额
var _thi=this;
this.totalMoney = 0;
this.profuctList.forEach( function ( item , index ) { if ( item.checked ) { _this.totalMoney += item.productPrice * item.productQuentity } } )
}
delete
delConfirm:function( item ) {
this.delFlag = ture ;
this.curProduct = item ;
} //存储对象
delProduct: function ( ) {
//this.delProduct.$delete( this.curProduct );
this.productList.indexOf( this.curProduct );
this.procuctList.splice( index, 1 )
}
直接遍历filterAddress 分页
computed:{ //这个生命周期很实用的,一般用在实时计算
filterAddress:function( ){
return this.addressList.slice( 0,this.limitNum); //slice会返回一个全新数组 这个新数组其实和addressList没什么关系addresssList还是保留着原来的数组数据
}
}
卡片选中
<li v-for = "(item , index) in filterAddress" v-bind:class="{ 'check':index==currentIndex }" @click="currentIndex=index"></div>
setDefault: function ( addressId ) { this.addressList.forEach( function ( address,index ) { if ( address.addressId==addressId ) { address.isDefault = true; } else { address.isDefault = false; }} ) }