美文网首页
vue3 使用 globalProperties 全局变量

vue3 使用 globalProperties 全局变量

作者: 邦_ | 来源:发表于2023-07-26 10:10 被阅读0次

Vue官方说明

选项式 API的写法 this还是可以调用

组合式 不能直接使用 this 调用 globalProperties 全局变量

定义


import md5 from 'js-md5'
const app = createApp(App)
app.config.globalProperties.$md5 = md5


使用

import { getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance()
  console.log(proxy.$md5('1212121212'))


相关文章

网友评论

      本文标题:vue3 使用 globalProperties 全局变量

      本文链接:https://www.haomeiwen.com/subject/zjkkpdtx.html