59、个人中心_显示收藏的商品数量
在个人中心显示 被收藏的商品
pages\user\index.js
Page({
data: {
userinfo:{},
// 被收藏的商品的数量
collectNums:0
},
onShow(){
const userinfo=wx.getStorageSync( "userinfo");
const collect=wx.getStorageSync("collect")||[];
this.setData({userinfo,collectNums:collect.length});
}
})
pages\user\index.wxml
<navigator url="/pages/collect/index">
<view class="his_num">{{collectNums}}</view>
<view class="his_name">收藏的商品</view>
</navigator>
pages\collect\index.json
{
"usingComponents": {},
"navigationBarTitleText": "商品收藏"
}
点击 收藏商品——>跳转到 商品收藏页面
添加新的编译模式 _商品收藏