商品选中按钮生效
This commit is contained in:
parent
92d8bbbfcd
commit
e3ce8acfc3
@ -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>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user