dandanyajin
今天更新博客了吗?

在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)

 

posted on 2022-08-23 15:38  dandanyajin  阅读(666)  评论(0编辑  收藏  举报