微信小程序?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)聽頁(yè)面加載 ? ?*/ ? onLoad: function (options) { ?? ? }, ? ? /** ? ?* 生命周期函數(shù)--監(jiān)聽頁(yè)面初次渲染完成 ? ?*/ ? onReady: function () { ?? ? }, ? ? /** ? ?* 生命周期函數(shù)--監(jiān)聽頁(yè)面顯示 ? ?*/ ? onShow: function () { ?? ? }, ? ? /** ? ?* 生命周期函數(shù)--監(jiān)聽頁(yè)面隱藏 ? ?*/ ? onHide: function () { ?? ? }, ? ? /** ? ?* 生命周期函數(shù)--監(jiān)聽頁(yè)面卸載 ? ?*/ ? onUnload: function () { ?? ? }, ? ? /** ? ?* 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(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)文章
一種基于瀏覽器的自動(dòng)小票機(jī)打印實(shí)現(xiàn)方案(js版)
這篇文章主要介紹了一種基于瀏覽器的自動(dòng)小票機(jī)打印實(shí)現(xiàn)方案(js版)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07利用JS做網(wǎng)頁(yè)特效_大圖輪播(實(shí)例講解)
下面小編就為大家?guī)?lái)一篇利用JS做網(wǎng)頁(yè)特效_大圖輪播(實(shí)例講解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-08-08Textarea輸入字?jǐn)?shù)限制實(shí)例(兼容iOS&安卓)
下面小編就為大家?guī)?lái)一篇Textarea輸入字?jǐn)?shù)限制實(shí)例(兼容iOS&安卓)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-07-07javascript實(shí)現(xiàn)簡(jiǎn)單搜索功能
這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)簡(jiǎn)單搜索功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-03-03es6中new.target的作用和使用場(chǎng)景簡(jiǎn)單示例分析
這篇文章主要介紹了es6中new.target的作用和使用場(chǎng)景,結(jié)合簡(jiǎn)單示例形式分析了es6中new.target的基本功能、原理、使用方法及操作注意事項(xiàng),需要的朋友可以參考下2020-03-03JavaScript實(shí)現(xiàn)簡(jiǎn)單抽獎(jiǎng)系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)簡(jiǎn)單抽獎(jiǎng)系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03移動(dòng)端日期插件Mobiscroll.js使用詳解
這篇文章主要為大家詳細(xì)介紹了移動(dòng)端日期插件Mobiscroll.js的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12