import { defHttp } from '/@/utils/http/axios';
1.Get请求
{
"axios模板Get请求代码": {
"prefix": "axios_get",
"body": [
"//功能:${1:axios请求xxx后端接口}",
"//时间:$CURRENT_YEAR年$CURRENT_MONTH月$CURRENT_DATE日 $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"//封装查询条件",
"let formData = {",
" xxx: this.xxx,",
"};",
"defHttp",
" .get({",
" url: this.url.xxx,",
" params: formData,",
" })",
" .then((result) => {",
" // 打印返回数据",
" console.info('🚀 ~ file:axios method: line:354 -----', result)",
" result.forEach(item => {",
"$4",
" })",
"$4",
" })",
" .finally(() => {",
" // 这里是无论成功或失败都会执行的方法",
"$4",
" });"
],
"description": "axios模板Get请求代码"
}
}
2.post请求
{
"axios模板Post请求代码": {
"prefix": "axios_post",
"body": [
"//功能:${1:axios请求xxx后端接口}",
"//时间:$CURRENT_YEAR年$CURRENT_MONTH月$CURRENT_DATE日 $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"//封装查询条件",
"let formData = {",
" xxx: this.xxx,",
"};",
"defHttp",
" .post({",
" url: this.url.xxx,",
" params: formData,",
" })",
" .then((result) => {",
" // 打印返回数据",
" console.info('🚀 ~ file:axios method: line:354 -----', result)",
" result.forEach(item => {",
"$4",
" })",
"$4",
" })",
" .finally(() => {",
" // 这里是无论成功或失败都会执行的方法",
"$4",
" });"
],
"description": "axios模板Post请求代码"
}
}