This article shares the specific code for mini-program switching positions for everyone for reference. The specific content is as follows
Switch position up and down of the applet
wxml
<view wx:for="{{companyData}}" wx:key="index" class="overHiden"> <view class="floarLeft">{{}}</view> <view class="floarRight" wx:if="{{index != 0}}" data-index="{{index}}" bindtap="topClick"> superior </view> <view class="floarRight" wx:if="{{index != -1}}" data-index="{{index}}" bindtap="bottomClick"> Down </view> </view>
js:
// pages/yidong/ Page({ /** * Initial data of the page */ data: { companyData:[ { id:0, name:'Product 1' }, { id:1, name:'Product 2' }, { id:2, name:'Product 3' }, { id:3, name:'Product 4' }, { id:4, name:'Product 5' } ] }, //Move the position upwardtopClick: function(e) { var that = this var index = var one = [index] var two = [index - 1] var index2 = index - 1 var data1 = "companyData[" + index + "]" var data2 = "companyData[" + index2 + "]" ({ [data1]: two, [data2]: one }) }, // Move the position downward bottomClick: function(e) { var that = this var index = var one = [index] var two = [index + 1] var index2 = index + 1 var data1 = "companyData[" + index + "]" var data2 = "companyData[" + index2 + "]" ({ [data1]: two, [data2]: one }) }, /** * Lifecycle function-listen to page load */ onLoad: function (options) { }, /** * Lifecycle function--listening page rendering is completed for the first time */ onReady: function () { }, /** * Lifecycle function--listening page display */ onShow: function () { }, /** * Lifecycle function--listening page hidden */ onHide: function () { }, /** * Lifecycle function-listening page uninstall */ onUnload: function () { }, /** * Page-related event handling function-listen to user pull-down action */ onPullDownRefresh: function () { }, /** * The handling function of the bottoming event on the page */ onReachBottom: function () { }, /** * User clicks to share */ onShareAppMessage: function () { } })
The above is for reference only, which is convenient for everyone to learn! !
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.