把 cartList[shopId]?.[item._id]?.[‘count’] 改成item.count 能获取到count,打印list也是有count属性。但是不明白list是通过getContentData方法获取到的,为什么会有count属性?
//html
<div class="product__item__num">
<span class="product__num__minus" @click="changeCartItemInfo(shopId, item._id, item, -1)">-</span>
<span class="product__num__text">{{cartList[shopId]?.[item._id]?.['count'] || 0}}</span>
<span class="product__num__plus" @click="changeCartItemInfo(shopId, item._id, item, 1)">+</span>
</div>
//js
const useCurrentListEffect = (currentTab, shopId) => {
const content = reactive({ list: [] })
const getContentData = async () => {
const result = await get(`/api/shop/${shopId}/products`, { tab: currentTab.value })
if (result?.errno === 0) {
content.list = result.data
}
}
watchEffect(() => { getContentData() })
const { list } = toRefs(content)
return { list }
}