Vue3 定义全局变量
在main.js文件中import { createApp } from 'vue';const app = createApp(App);app.config.globalProperties.$key = "内容";// 定义全局变量app.mount('#app');在使用时import {getCurrentInstance} from 'vue';export default {setu
·
在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);
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)