main.ts中通过 config.globalProperties 进行全局挂载
app.config.globalProperties.$cache = cache
vue后缀文件中在setup中使用
import { getCurrentInstance} from 'vue'
const { proxy } = getCurrentInstance()
proxy.$cache
最后定义$cache类型
在src/shims-vue.d.ts文件中添加
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$message: ElMessage
$cache: ICacheType
}
}