Vue3中全局注册变量
Vue2中声明全局变量
在main.js中定义全局变量
import Vue from 'vue'
Vue.prototype.postRequest = postRequest;
//使用prototype进行注册,以后可以在页面进行调用了
//其中postRequest为定义的一个方法
Vue3中定义
Vue3中使用createApp()
const app = createApp(App)
// vue3中全局变量改变了(prototype->config)
app.config.globalProperties.getRequest = getRequest;