在main.js文件中
import { createApp } from 'vue';
const app = createApp(App);
app.config.globalProperties.$key = "内容";// 定义全局变量
app.mount('#app');
在使用时
import {getCurrentInstance} from 'vue';
export default {
setup(){
const { proxy } = getCurrentInstance();
console.log(proxy.$key);
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)