这篇文章主要讲解了“微信小程序怎么实现购物车选择规格颜色效果”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“微信小程序怎么实现购物车选择规格颜色效果”吧!
具体内容如下:
wxml:
<view> <view>规格:</view> <view class='dis'> <block wx:for="{{guige}}"> <view class="{{gindex==index?'color':''}}" bindtap='guige' data-index='{{item.id}}' data-current='{{index}}'>{{item.name}}</view> </block> </view> <view>颜色:</view> <view class='dis'> <block wx:for="{{color}}"> <view class="{{cindex==index?'color':''}}" bindtap='color' data-index='{{item.id}}' data-current='{{index}}'>{{item.name}}</view> </block> </view></view><view>{{guige[gindex].name}}:{{color[cindex].name}}</view>
js:
// pages/guige/guige.jsPage({ data: { guige:[ {id:1,name:'M'}, {id:2,name:'L'}, {id:3,name:'X'}, {id:4,name:'S'} ], color:[ {id:5,name:'红'}, { id: 6, name: '橙'}, { id: 7, name: '黄'}, { id: 8, name: '绿'} ] }, guige:function(e){ this.setData({ gid: e.currentTarget.dataset.index, gindex: e.currentTarget.dataset.current, }) }, color:function(e){ this.setData({ cid: e.currentTarget.dataset.index, cindex: e.currentTarget.dataset.current, }) }, onLoad: function (options) { }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { }, onShareAppMessage: function () { }})
css:
.color{ color: red}.dis{display: flex;justify-content: space-around}
感谢各位的阅读,以上就是“微信小程序怎么实现购物车选择规格颜色效果”的内容了,经过本文的学习后,相信大家对微信小程序怎么实现购物车选择规格颜色效果这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!