vue 操控数组移动【上移,下移】

直接上方法了   this.formData.jsonList 为数组,直接替换成你的就行了

 hanldeTop( index) {
      console.log(index)

      if (index !== 0) {
        var tempOption = this.formData.jsonList[index - 1] //存储前一个
        this.$set(
          this.formData.jsonList,
          index - 1,
          this.formData.jsonList[index]
        )
        this.$set(this.formData.jsonList, index, tempOption)
      }
    },
    hanldeBottom(index) {
      if (index !== 0) {
        var tempOption = this.formData.jsonList[index + 1] //存储后一个
        this.$set(
          this.formData.jsonList,
          index + 1,
          this.formData.jsonList[index]
        )
        this.$set(this.formData.jsonList, index, tempOption)
      }
    },


相关内容

发表评论

验证码:
点击我更换图片

最新评论