微信小程序?qū)崿F(xiàn)購(gòu)物車選擇規(guī)格顏色效果
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)購(gòu)物車選擇規(guī)格顏色效果的具體代碼,供大家參考,具體內(nèi)容如下
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({
?
? /**
? ?* 頁(yè)面的初始數(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)聽(tīng)頁(yè)面加載
? ?*/
? onLoad: function (options) {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成
? ?*/
? onReady: function () {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示
? ?*/
? onShow: function () {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏
? ?*/
? onHide: function () {
??
? },
?
? /**
? ?* 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載
? ?*/
? onUnload: function () {
??
? },
?
? /**
? ?* 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶下拉動(dòng)作
? ?*/
? onPullDownRefresh: function () {
??
? },
?
? /**
? ?* 頁(yè)面上拉觸底事件的處理函數(shù)
? ?*/
? onReachBottom: function () {
??
? },
?
? /**
? ?* 用戶點(diǎn)擊右上角分享
? ?*/
? onShareAppMessage: function () {
??
? }
})css:
.color{
? color: red
}
.dis{display: flex;justify-content: space-around}以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序?qū)崿F(xiàn)簡(jiǎn)單購(gòu)物車功能
- 微信小程序?qū)崿F(xiàn)購(gòu)物車功能
- 微信小程序?qū)崿F(xiàn)加入購(gòu)物車滑動(dòng)軌跡
- 微信小程序?qū)崿F(xiàn)多選框全選與反全選及購(gòu)物車中刪除選中的商品功能
- 微信小程序?qū)崿F(xiàn)購(gòu)物車代碼實(shí)例詳解
- 微信小程序利用swiper+css實(shí)現(xiàn)購(gòu)物車商品刪除功能
- 微信小程序購(gòu)物車、父子組件傳值及calc的注意事項(xiàng)總結(jié)
- 微信小程序?qū)崙?zhàn)篇之購(gòu)物車的實(shí)現(xiàn)代碼示例
- 微信小程序之購(gòu)物車功能
- 微信小程序 購(gòu)物車簡(jiǎn)單實(shí)例
相關(guān)文章
bootstrap中使用google prettify讓代碼高亮的方法
使用google prettify 讓代碼高亮非常漂亮,接下來(lái)通過(guò)本文給大家介紹bootstrap中使用google prettify讓代碼高亮的方法,感興趣的朋友一起看看吧2016-10-10
JS與Ajax Get和Post在使用上的區(qū)別實(shí)例詳解
這篇文章主要介紹了JS與Ajax Get和Post在使用上的區(qū)別實(shí)例詳解的相關(guān)資料,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06
bootstrap table動(dòng)態(tài)加載數(shù)據(jù)示例代碼
本篇文章主要介紹了bootstrap table動(dòng)態(tài)加載數(shù)據(jù)示例代碼,可以實(shí)現(xiàn)點(diǎn)擊選擇按鈕,彈出模態(tài)框,加載出關(guān)鍵詞列表,有興趣的可以了解一下。2017-03-03
JavaScript實(shí)現(xiàn)頁(yè)面動(dòng)態(tài)驗(yàn)證碼的實(shí)現(xiàn)示例
這篇文章主要介紹了JavaScript實(shí)現(xiàn)頁(yè)面動(dòng)態(tài)驗(yàn)證碼的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
NestJs使用Mongoose對(duì)MongoDB操作的方法
這篇文章主要介紹了NestJs使用Mongoose對(duì)MongoDB操作的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02
跟我學(xué)習(xí)javascript的函數(shù)調(diào)用和構(gòu)造函數(shù)調(diào)用
跟我學(xué)習(xí)javascript的函數(shù)和構(gòu)造函數(shù)調(diào)用,主要包括三方面內(nèi)容函數(shù)調(diào)用、方法調(diào)用以及構(gòu)造函數(shù)調(diào)用,想要了解這些內(nèi)容的朋友千萬(wàn)不要錯(cuò)過(guò)下面的內(nèi)容。2015-11-11

