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

微信小程序?qū)崿F(xiàn)給循環(huán)列表添加點(diǎn)擊樣式實(shí)例

 更新時(shí)間:2017年04月26日 16:51:28   投稿:lqh  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)給循環(huán)列表添加點(diǎn)擊樣式實(shí)例的相關(guān)資料,需要的朋友可以參考下

微信小程序?qū)崿F(xiàn)給循環(huán)列表添加點(diǎn)擊樣式實(shí)例

微信小程序有個(gè)屬性hover-class='active',是指當(dāng)點(diǎn)擊列表元素時(shí)當(dāng)按下鼠標(biāo)左鍵會(huì)顯示active樣式,但是鼠標(biāo)離開樣式就會(huì)復(fù)原.可以參考以下解決方案,直接上代碼:

wxml:

<view class="taga">
 <view class="tag-title">標(biāo)簽</view>
 <view class="tag-box">
 <view wx:for="{{taga}}" wx:key="id" wx:for-index="i">
 <view class="taga-item {{currentItem==item.id?'active-tag':''}}" data-id="{{item.id}}" bindtap="tagChoose">{{item.name}}</view>
 </view>
 </view>
 </view>

js文件:

 tagChoose:function(options){
 var that = this
 var id = options.currentTarget.dataset.id;
 console.log(id)
 //設(shè)置當(dāng)前樣式
 that.setData({
 'currentItem':id
 })


 }

核心點(diǎn):class=”taga-item {{dateCurrent==item.id?'active-tag':”}}”模板文件中使用三元運(yùn)算符,通過dateCurrent指定當(dāng)前item的id

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論