vue接口返回值给后台

  • Post author:
  • Post category:vue


1.接口

getOrder(param){
  return request({
    method: 'get',
    url: '/order/loadlist',
    params: param
  })
},

2.使用

methods: {
  getOrderList(){
    let param = {
      limit: this.limit,
      page: this.page
    }
    service.getOrder(param).then(res=>{
      const data = res.data
      if (data.code == 200) {
        this.tableData = data.data
        console.log(res)
        this.limit=data.limit
        this.page=data.page
        this.count=data.count
      } else {
        this.tableData = []
        this.count = 0
        this.page = 1
        this.limit = 10
      }
    })
  }, 
//分页
handleSizeChange(val) {
  console.log(`每页 ${val} 条`);
  this.limit = val
  this.getOrderList()
  this.allSelect = !this.allSelect
  this.isActive = !this.isActive;
},
handleCurrentChange(val) {
  console.log(`当前页: ${val}`);
  this.page = val
  this.getOrderList()
  this.allSelect = !this.allSelect
  this.isActive = !this.isActive;
},
},
mounted(){
 this.getOrderList()
},



版权声明:本文为Guoyu1_原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。