/* 挂载全局对象 start */ app.config.globalProperties.$http = Axios app.config.globalProperties.$utils = Utils
使用
import { ref, reactive, getCurrentInstance } from 'vue' // 方法一 start const currentInstance = getCurrentInstance() const { $http, $message, $route } = currentInstance.appContext.config.globalProperties // 方法二 start const { proxy } = getCurrentInstance() function getData() { proxy.$http({ url: '/api/v1/posts/list' }).then(res=>{ let { data } = res.data console.log(data) }) }