/** * 获取用户信息 */ const userInfo = reactive({ name: '', headImg: '' })
//用户信息接口的调用 const getUserInfoData = async () => { const res = await getUserInfo() if (res?.name && res?.headImg) { userInfo.name = res.name userInfo.headImg = res.headImg } }
该函数用于判断res对象中的name和headImg属性是否存在,并且这两个属性的值都不为null或undefined。如果满足条件,则执行后续的代码块