在main.js中
import request from '@/utils/request' import { getToken, setToken, removeToken, setFamily, getFamily } from '@/utils/auth' //挂载全局方法; app.config.globalProperties.$http = request; app.config.globalProperties.$setFamily = setFamily; app.config.globalProperties.$getFamily = getFamily;
使用
import {getCurrentInstance} from 'vue'; const {appContext} = getCurrentInstance(); const globalProxy = appContext.config.globalProperties; globalProxy.$setFamily(res)