本文实例为大家分享了小程序实现上下移动切换位置的具体代码,供大家参考,具体内容如下
<view wx:for="{{companyData}}" wx:key="{{item.id}}" class="overHiden"> <view class="floarLeft">{{item.name}}</view> <view class="floarRight" wx:if="{{index != 0}}" data-index="{{index}}" bindtap="topClick"> <image src="/UploadFiles/2021-04-02/32.png">data{ companyData:[ { id:0, name:'产品1' }, { id:1, name:'产品2' }, { id:2, name:'产品3' }, { id:3, name:'产品4' }, { id:4, name:'产品5' } ] }//位置向上移动 topClick: function(e) { var that = this var index = e.currentTarget.dataset.index var one = that.data.companyData[index] var two = that.data.companyData[index - 1] var index2 = index - 1 var data1 = "companyData[" + index + "]" var data2 = "companyData[" + index2 + "]" that.setData({ [data1]: two, [data2]: one }) }, // 位置向下移动 bottomClick: function(e) { var that = this var index = e.currentTarget.dataset.index var one = that.data.companyData[index] var two = that.data.companyData[index + 1] var index2 = index + 1 var data1 = "companyData[" + index + "]" var data2 = "companyData[" + index2 + "]" that.setData({ [data1]: two, [data2]: one }) }以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“小程序实现上下移动切换位置”评论...