vue3使用 getCurrentInstance 遇到的疑惑,请问有谁可以解释一下下面两种不同写法的区别吗?
第一种:
const a1= getCurrentInstance()?.proxy;
a1?.$toast({type: 'error', text: '登录失败' });
第二种:
const a2= getCurrentInstance();
a2.proxy.$toast({type: 'error', text: '登录失败' });
vue3使用 getCurrentInstance 遇到的疑惑,请问有谁可以解释一下下面两种不同写法的区别吗?
第一种:
const a1= getCurrentInstance()?.proxy;
a1?.$toast({type: 'error', text: '登录失败' });
第二种:
const a2= getCurrentInstance();
a2.proxy.$toast({type: 'error', text: '登录失败' });