小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

小程序--點(diǎn)擊顯示與隱藏-動態(tài)更改img-src 路徑

 webpengli 2019-06-20

這里的示列是圖標(biāo)的切換-選中與未選中樣式-因點(diǎn)擊此圖標(biāo)是直接跳轉(zhuǎn)其它頁面的-所以沒有考慮點(diǎn)擊顯示再次點(diǎn)擊隱藏效果(類似js的toggle效果)-因?yàn)椴恍枰?/p>



方法一:--動態(tài)更改img-src路徑--直接更換src路徑的話-初始渲染會延遲-閃動-所以后來又寫了第二種方法-解決了此問題

wxml:

<view class='rotate-list' style='transform:rotate({{angle}}deg);width:{{rotate_list_w}}rpx; height:{{rotate_list_w}}rpx;' bindtouchstart='onTouchStart' bindtouchmove='onTouchMove' bindtouchend='onTouchEnd'>

<image class="rotate-item " bindtap='btnicon' wx:for="{{rotateList}}" wx:key="index" data-index="{{item.index}}" style='top:{{item.top}}rpx;left:{{item.left}}rpx;transform:rotate({{-angle}}deg);' src='{{item.src}}'></image>

</view>

wxjs:

/* icon點(diǎn)擊事件*/

btnicon: function (e) {

var _that=this;

// 被點(diǎn)擊時(shí)傳遞的參數(shù)

var queryIndex = e.currentTarget.dataset['index'];

var select_icon = _that.select_icon();

// 被點(diǎn)擊時(shí)傳遞的參數(shù)

var queryIndex = e.currentTarget.dataset['index'];

// rotateList獲取到原圖片數(shù)組--iconList_src-重定義數(shù)組圖片src路徑--iconList_src定義重新賦值圖片src的值

var rotateList = _that.data.rotateList,

iconList_src = 'rotateList[' + queryIndex + '].src',

iconList_srcy = rotateList[queryIndex].src,//原始圖片路徑

icon_src = select_icon[queryIndex].src;

_that.setData({

[iconList_src]: icon_src

});

setTimeout(function () {

_that.setData({

[iconList_src]: iconList_srcy

});

}, 800);

},

/**選中樣式的icon */

select_icon: function (select){

var _that = this;

var select_rotateList=[

{ src: 'https://s2./2019/06/18/VLEB80.th.png'},

{ src: 'https://s2./2019/06/18/VLEHqe.th.png'},

{ src: 'https://s2./2019/06/18/VLEOIA.th.png'},

{ src: 'https://s2./2019/06/18/VLEjPI.th.png'},

{ src: 'https://s2./2019/06/18/VLEzxf.th.png'},

{ src: 'https://s2./2019/06/18/VLVVGq.th.png' },

{ src: 'https://s2./2019/06/18/VLViZQ.th.png' },

{ src: 'https://s2./2019/06/18/VLVkIs.th.png' },

{ src: 'https://s2./2019/06/18/VLVZR0.th.png'}

];

return select_rotateList;

},

方法二:點(diǎn)擊顯示與隱藏

wxml:

<view class='rotate-list' style='transform:rotate({{angle}}deg);width:{{rotate_list_w}}rpx; height:{{rotate_list_w}}rpx;' bindtouchstart='onTouchStart' bindtouchmove='onTouchMove' bindtouchend='onTouchEnd'>

<image class="rotate-item hide{{item.contactName?'':'show'}}" bindtap='btnicon' wx:for="{{rotateList}}" wx:key="index" data-index="{{item.index}}" style='top:{{item.top}}rpx;left:{{item.left}}rpx;transform:rotate({{-angle}}deg);' src='{{item.src}}'></image>

<image class="rotate-item hide{{item.contactName?'':'show'}}" wx:for="{{selectlist}}" wx:key="index" data-index="{{item.index}}" style='top:{{item.top}}rpx;left:{{item.left}}rpx;transform:rotate({{-angle}}deg);' src='{{item.src}}'></image>

</view>

wxcss:

.hide{display: none;}

.show{display: block;

wxjs:

/* icon點(diǎn)擊事件*/

btnicon: function (e) {

var _that=this;

// 被點(diǎn)擊時(shí)傳遞的參數(shù)

var queryIndex = e.currentTarget.dataset['index'];

var rotateList = _that.data.rotateList;

var rotateList_contactName = 'rotateList[' + queryIndex + '].contactName';

var select_icon = _that.select_icon();

var selectlist_contactName = 'selectlist[' + queryIndex + '].contactName';

var rotateList_c = rotateList[queryIndex].contactName;

var select_icon_c = select_icon[queryIndex].contactName;

_that.setData({

[rotateList_contactName]: !rotateList_c,

[selectlist_contactName]: !select_icon_c

});

},

/**選中樣式的icon */

select_icon: function (select){

var _that = this;

// rotateList獲取到原圖片數(shù)組

var rotateList = _that.data.rotateList;

var icon_src;

_that.setData({

selectlist: rotateList

});

var select_rotateList=[

{ src: 'https://s2./2019/06/18/VLEB80.th.png', contactName: true},

{ src: 'https://s2./2019/06/18/VLEHqe.th.png', contactName: true},

{ src: 'https://s2./2019/06/18/VLEOIA.th.png', contactName: true},

{ src: 'https://s2./2019/06/18/VLEjPI.th.png', contactName: true},

{ src: 'https://s2./2019/06/18/VLEzxf.th.png', contactName: true},

{ src: 'https://s2./2019/06/18/VLVVGq.th.png', contactName: true },

{ src: 'https://s2./2019/06/18/VLViZQ.th.png', contactName: true },

{ src: 'https://s2./2019/06/18/VLVkIs.th.png', contactName: true },

{ src: 'https://s2./2019/06/18/VLVZR0.th.png', contactName: true}

];

//替換src路徑

for (var i = 0; i < rotateList.length; i++) {

icon_src = 'selectlist[' + i + '].src';

var selectlist_contactName = 'selectlist[' + i + '].contactName';

_that.setData({

[icon_src]: select_rotateList[i].src,

[selectlist_contactName]: select_rotateList[i].contactName

});

}

return select_rotateList;

},

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多