例:新增一个example的模块的getExampleList请求
在http -> modules下新增example.js
新增 getExampleList 接口
import axios from '../index' // 导入http中创建的axios实例 import { config } from '../config' // 导入http中创建的axios实例 export default { /** * 获取例子列表 */ export const getExampleList = (args) => { return axios({ url: `${config.api_url.djfansg}/api/activity-item/, // 请求地址 data: args, // 请求参数 method: 'POST', // 请求类型 showLoading: false, // 该请求是否需要全局loading option: { // 额外参数 'name': 'll' } }) } }在vue的script中,调用getDepartmentList
import { getExampleList } from '@/src/http/example'; // 必须引入example,拿到example.js中的getExampleList接口。 let args = { param1: '', ... } getExampleList(args, res => { console.log(res) })