// main.ts声明(需要挂载前定义)
app.config.globalProperties.$test = 'hello world!!'
app.mount('#app')
// 在页面中调用
import { getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
console.log(proxy.$test); // 打印hello world!!
微信扫一扫
// main.ts声明(需要挂载前定义)
app.config.globalProperties.$test = 'hello world!!'
app.mount('#app')
// 在页面中调用
import { getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
console.log(proxy.$test); // 打印hello world!!
相关推荐