0
点赞
收藏
分享

微信扫一扫

详情页分页实现

眼君 2022-03-15 阅读 73
javascript
  // 上一条
    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 条评论