Vue3定义全局函数和变量
cv大魔王 2021-08-03 vue3vite 分享
Vue3没有Prototype属性,使用app.config.globalProperties代替,然后去定义变量和函数。
Vue2
Vue.prototype.$http = () => {}
Vue3的写法,一般写在main.js中
const app = createApp({})
app.config.globalProperties.$http = () => {}
评论区
暂无评论~~