入口文件挂载
// main.ts
app.config.globalProperties.$test = "test"
使用
import {getCurrentInstance} from 'vue'
setup(){
const gps= getCurrentInstance()!.appContext.config.globalProperties
// 读取或者使用
console.log(gps.$test)
}
入口文件挂载
// main.ts
app.config.globalProperties.$test = "test"
使用
import {getCurrentInstance} from 'vue'
setup(){
const gps= getCurrentInstance()!.appContext.config.globalProperties
// 读取或者使用
console.log(gps.$test)
}
本文标题:vue3全局挂载
本文链接:https://www.haomeiwen.com/subject/yvxfmrtx.html
网友评论