前端页面在根目录下的文件夹pages=》index=》index.vue
接口统一在根目录下的文件夹api=》index(自己模块归类文件夹里)=》...
前端页面代码:
引入统一的接口文件
import { getAds, getData } from '../../api/index/index.js'
使用如下:
getData().then(res => { if (res.code == 200) { } else {} }).catch(error => { })
前端接口统一代码:
import http from '@/api/http.js' import config from '@/config/index.js' export function getAds(params) { return http.get(`****/ads`, params); } export function getData (data) { return http.post('***/getData',data); }