// main.ts声明(需要挂载前定义)
app.config.globalProperties.$test = 'hello world!!'
app.mount('#app')
// 在页面中调用
import { getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
console.log(proxy.$test); // 打印hello world!!
vue3访问全局globalProperties
阅读 167
2022-02-26
// main.ts声明(需要挂载前定义)
app.config.globalProperties.$test = 'hello world!!'
app.mount('#app')
// 在页面中调用
import { getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
console.log(proxy.$test); // 打印hello world!!
相关推荐
精彩评论(0)