一、引入
import { getCurrentInstance } from 'vue'
二、定义
const { proxy } = getCurrentInstance()
三、请求
(1)、get请求
proxy.$ajax.get('/api/user_list/',{
params: {
sort: '-id',
page: 1,
limit: 12
}
})
.then(res => {
console.log("res", res)
}).catch(err => {
console.log("err", err)
})
(2)、post请求
proxy.$ajax.post('/api/user_delete/', {"id": id})
.then(res => {
console.log("res", res)
})
.catch(err => {
console.log("err", err)
})