欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序實現(xiàn)購物車選擇規(guī)格顏色效果

 更新時間:2022年01月21日 12:10:58   作者:小丫么小菜菜  
這篇文章主要為大家詳細介紹了微信小程序實現(xiàn)購物車選擇規(guī)格顏色選中效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序實現(xiàn)購物車選擇規(guī)格顏色效果的具體代碼,供大家參考,具體內容如下

wxml:

<view>
? <view>規(guī)格:</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({
?
? /**
? ?* 頁面的初始數(shù)據(jù)
? ?*/
? 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,
? ? })
? },
? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面加載
? ?*/
? onLoad: function (options) {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
? ?*/
? onReady: function () {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面顯示
? ?*/
? onShow: function () {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面隱藏
? ?*/
? onHide: function () {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面卸載
? ?*/
? onUnload: function () {
??
? },
?
? /**
? ?* 頁面相關事件處理函數(shù)--監(jiān)聽用戶下拉動作
? ?*/
? onPullDownRefresh: function () {
??
? },
?
? /**
? ?* 頁面上拉觸底事件的處理函數(shù)
? ?*/
? onReachBottom: function () {
??
? },
?
? /**
? ?* 用戶點擊右上角分享
? ?*/
? onShareAppMessage: function () {
??
? }
})

css:

.color{
? color: red
}
.dis{display: flex;justify-content: space-around}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論