get请求数据
用params传参数是一个对象
//请求数据 insuranceClassifyData () { this.$http.get(Apis.INSURANCE_CLASSIFY, { params: { pageNo: 1, sortBy: 'weight:desc' } }) .then(resp => { if (resp.data.statu === 200 && resp.data.message === 'SUCCESS') { console.log(resp.data.data.list) this.classifyData = resp.data.data.list } }) .catch(resp => { console.log(resp) }) },
post和put上传数据
/* * 表单提交事件/新建/修改 * formName:要提交的那个表单的表单对象 */ submitClassifyForm (formName) { if (formName.cargoCategoryId) { this.$http.put(Apis.INSURANCE_CLASSIFY + `/${formName.cargoCategoryId}`, formName) .then(resp => { location.reload() //成功以后刷新页面 }) .catch(resp => { console.log(resp) }) } else { this.$http.post(Apis.INSURANCE_CLASSIFY, formName) .then(resp => { location.reload() }) .catch(resp => { console.log(resp) }) } },
delete删除数据
// 删除事件 deleteClassify (data) { this.$http.delete(Apis.INSURANCE_CLASSIFY + `/${data.cargoCategoryId}`) .then(resp => { location.reload() }) .catch(resp => { console.log(resp) }) },
转载:https://www.jianshu.com/p/445f0a712435