VUE get请求与post请求


   // get请求获取数据(有参数)
    getDataList: function () {
      this.$http.get('/api/edu_classroom', {
        params: {
          page: this.pageIndex,
          size: this.pageSize,
          sort: "createDate desc"
        }
      }).then((response) => {
        this.dataList = response.data.data.records
        this.total = response.data.data.total
      })
    },
 
 //post请求查询 事例
    findDate: function () {
      this.$http.post('/api/edu_classroom/findByEntity?page=' + this.pageIndex + '&size=' + this.pageSize, this.searchInfo).then((response) => {
        this.dataList = response.data.data.records
        this.total = response.data.data.total

      })
    },
 
//post请求新增
   this.$http.post('/api/edu_classroom/add', this.info).then((response) => {
              if (response.data.success) {
                this.showDialog = false
                this.getDataList()
                this.$notify({
                  title: 'ok',
                  message: response.data.msg
                })
              } else {
                this.$notify.error({
                  title: '错误',
                  message: response.data.msg
                })
              }
            })
//post请求修改
 this.$http.post('/api/edu_classroom/updateById', this.info).then((response) => {
              if (response.data.success) {
                this.showDialog = false
                this.getDataList()
                this.$notify({
                  title: 'ok',
                  message: response.data.msg
                })
              } else {
                this.$notify.error({
                  title: '错误',
                  message: response.data.msg
                })
              }
            })
          }
 
 
 // get请求 删除操作
    deleteHandle: function (id) {
      // 处理IDS
      var uuids = id ? [id] : this.dataListSelections.map(item => {
        return item.uuid
      })
      // 提示用户删除
      this.$confirm(`确定删除操作?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http.get('/api/edu_classroom/removeByIds', {
          params: {
            uuids: uuids.join(',')
          }
        }).then((response) => {
          this.$notify({
            title: 'OK',
            message: '删除成功!'
          })
          this.getDataList()
        })
      }).catch(() => { })
    },


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM