本文实例为大家分享了微信小程序实现购物车选择规格颜色效果的具体代码,供大家参考,具体内容如下 wxml: <view> <view>规格:</vie
本文实例为大家分享了微信小程序实现购物车选择规格颜色效果的具体代码,供大家参考,具体内容如下
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.js
Page({
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}
--结束END--
本文标题: 微信小程序实现购物车选择规格颜色效果
本文链接: https://lsjlt.com/news/163262.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0