圆周率呀 2022-11-10 17:47 采纳率: 0%
浏览 67

vue3使用 getCurrentInstance 遇到的疑惑

vue3使用 getCurrentInstance 遇到的疑惑,请问有谁可以解释一下下面两种不同写法的区别吗?

第一种:
const a1= getCurrentInstance()?.proxy;
a1?.$toast({type: 'error', text: '登录失败' });
第二种:
const a2= getCurrentInstance();
a2.proxy.$toast({type: 'error', text: '登录失败' });

  • 写回答

2条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-11-10 20:29
    关注
    评论

报告相同问题?

问题事件

  • 创建了问题 11月10日