详情页分页实现

眼君

关注

阅读 73

2022-03-15

  // 上一条
    prevInfo() {// this.ids为所有数据的id集合
      let id = this.$route.query.id;
      let currentId = this.ids.filter(item => item == id); //当前的id
      let preIndex = this.ids.indexOf(currentId[0]);
      if (preIndex == 0) {
        this.$message.warning("已经是第一条数据了!");
        return;
      } else {
        this.$router.push({
          path: "/soilrollout/info",
          query: {
            id: this.ids[preIndex - 1]
          }
        });
        this.$nextTick(() => {
          this.getMsg(this.ids[preIndex - 1]);
          this.$forceUpdate()
        })
      }
    },
    // 下一条
    nextInfo() { // this.ids为所有数据的id集合
      let id = this.$route.query.id;
      let currentId = this.ids.filter(item => item == id); //当前的id
      let preIndex = this.ids.indexOf(currentId[0]);
      if (preIndex == this.ids.length - 1) {
        this.$message.warning("已经是最后一条数据了!");
        return;
      } else {
        this.$router.push({
          path: "/soilrollout/info",
          query: {
            id: this.ids[preIndex + 1]
          }
        });
        this.$nextTick(() => {
          this.getMsg(this.ids[preIndex + 1]);
          this.$forceUpdate()
        })
      }
    },

精彩评论(0)

0 0 举报