首页 > TAG信息列表 > appContext

Vue3中如何使用this

vue3提供了getCurrentInstance ,通过这个属性,直接使用ctx是错误的,需要找到全局属性globalProperties import { getCurrentInstance } from 'vue' const instance = getCurrentInstance() const _this= instance.appContext.config.globalProperties 这里的_this就相当于vue2里的th