在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);
  }
}

Logo

前往低代码交流专区

更多推荐