E企盈营销工具技术服务商 热线:4006-838-530

[项目]小程序数组操作(上移下移编辑删除)

E企盈直播平台营销卖货系统

//编辑–取出指定下标并跳转到编辑页面toRemake:function(){    var questions = [];    questions = wx.getStorageSync(‘questions’);    var index = this.data.idx;    var question = questions[index];    var qType = question.type;    if(qType===’单选’){      wx.navigateTo({        url: ‘../single/single?idx=’+this.data.idx,      })    }else if(qType===’多选’){      wx.navigateTo({        url: ‘../check/check?idx=’ + this.data.idx,      })    }else{      wx.navigateTo({        url: ‘../input/input?idx=’ + this.data.idx,      })    }     },//删除指定下标的元素,重新保存数组,并刷新页面  toDelete:function(){    var questions = wx.getStorageSync(‘questions’);    var index = this.data.idx;    questions.splice(index, 1);    wx.setStorageSync(“questions”, questions);    wx.redirectTo({      url: ‘../lookServey/lookServey’,    })  },  //上移并刷新页面和下移并刷新页面  toChange:function(){    var questions = this.data.questions;   if(this.data.idx===0){     wx.showToast({       title: ‘已经在第一位了’,       icon:”none”     })   }else{     this.changeUp(questions, this.data.idx);     wx.setStorageSync(“questions”, questions);     wx.redirectTo({       url: ‘../lookServey/lookServey’,     })   }      },  toChange1: function () {    var questions = this.data.questions;if(this.data.idx===questions.length-1){  wx.showToast({    title: ‘已经在最后一位了’,    icon:’none’  })}else{  this.changeDown(questions, this.data.idx);  wx.setStorageSync(“questions”, questions);  wx.redirectTo({    url: ‘../lookServey/lookServey’,  })}     },//上移方法  changeUp: function(arr, index){    var temp;    if(index===0 || index arr.length – 1) {      return arr;    }    temp = arr[index];    arr[index] = arr[index – 1];    arr[index – 1] = temp;    return arr;   },//下移方法  changeDown: function (arr, index) {    var temp;    if (index === arr.length-1) {      return arr;    }    temp = arr[index];    arr[index] = arr[index +1];    arr[index + 1] = temp;    return arr;  },

赞(0) 打赏
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » [项目]小程序数组操作(上移下移编辑删除)
分享到: 更多 (0)
E企盈小程序直播营销卖货系统
E企盈直播平台营销卖货系统

评论 抢沙发

E企盈小程序开发

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏