商品选中按钮生效

This commit is contained in:
jqtmviyu@gmail.com 2021-03-04 22:46:22 +08:00
parent 92d8bbbfcd
commit e3ce8acfc3

View File

@ -1,8 +1,8 @@
<template> <template>
<view class="cart"> <view class="cart">
<view class="cart_item" v-for="item in cartList" :key="item.goods_id"> <view class="cart_item" v-for="(item, index) in cartList" :key="item.goods_id">
<!-- 1. 选择按钮 --> <!-- 1. 选择按钮 -->
<radio class="cart_item_radio" :checked="item.goods_select" color="#e03440" /> <radio class="cart_item_radio" @tap="itemSelectChangeHandle(index)" :checked="item.goods_select" color="#e03440" />
<!-- 2. 商品组件 --> <!-- 2. 商品组件 -->
<goodsItem :item="item" /> <goodsItem :item="item" />
<!-- 3. 计数器 --> <!-- 3. 计数器 -->
@ -34,7 +34,14 @@ export default {
onShow() { onShow() {
const cartList = uni.getStorageSync("cartList") || []; const cartList = uni.getStorageSync("cartList") || [];
this.cartList = cartList this.cartList = cartList
} },
methods: {
//
itemSelectChangeHandle(index){
//
this.cartList[index].goods_select = !this.cartList[index].goods_select
}
},
} }
</script> </script>