<div class="rui-from-li rui-flex-ac" v-for="item,index in userInfo.shops">
<div class="rui-fg">
<div class="rui-flex-ac">
<img :src="icon.changeShopIcon" class="rui-change-icon" alt="">
<div class="rui-fs30 rui-ml25 rui-line1 rui-fg">{{item.hallname}}</div>
</div>
<div class="rui-flex-ac rui-mt20">
<img :src="icon.changeAddressIcon" class="rui-change-icon" alt="">
<div class="rui-fs30 rui-ml25 rui-line1 rui-fg">{{item.halladdress}}</div>
</div>
</div>
<van-checkbox v-model="item.checked" @click="getCurrentShop(index, item)" checked-color="#e24c4e"></van-checkbox>
</div>
getCurrentShop(index, shop){
console.log(shop)
console.log(JSON.stringify(shop))
if(!shop.checked){
console.log('取消选中,不执行切换操作!')
return false;
}
this.qywap.getShopIdBySharInfo({shareId: shop.shareId}).then(res => {
localStorage.setItem('skid', res.skid)
localStorage.setItem('shopId', res.tyfoShopid)
localStorage.setItem('scene',shop.shareId)
history.back()
})
}
}
click 事件的执行在 v-model 的修改之前,导致的结果是取消操作,不执行打断失效!
getCurrentShop(index, shop){
this.userInfo.shops[index].checked = !this.userInfo.shops[index].checked;
console.log(shop)
console.log(JSON.stringify(shop))
if(!shop.checked){
console.log('取消选中,不执行切换操作!')
return false;
}
this.qywap.getShopIdBySharInfo({shareId: shop.shareId}).then(res => {
localStorage.setItem('skid', res.skid)
localStorage.setItem('shopId', res.tyfoShopid)
localStorage.setItem('scene',shop.shareId)
history.back()
})
}
}
由于没有百度到类似的问题,所以可能是用的方法错误,如有知道正确方法的,请告知!此篇博客只作为开发过程遇到问题的记录!