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