Vue3 获取上下文对象

// 获取composition API 上下文对象
const { ctx } = getCurrentInstance()
 
vue2 可以通过this.$xxx 获取在main.js中挂载的全局对象
vue3中的composition API 需要通过从vue中导入getCurrentInstance 方法 来获取上下文对象  然后ctx.$xxx 使用全局对象
posted @ 2021-07-05 16:13  LJLong  阅读(2221)  评论(0)    收藏  举报