booleen
booleen
  • 发布:2025-03-17 18:07
  • 更新:2025-03-17 18:07
  • 阅读:17

为啥obj.getAny(path) as any时候会报错

分类:uni-app x

封装了个函数,通过路径访问对象

export function getValueByPath(obj:any, path:string):any|null {
if(obj instanceof UTSJSONObject){
//为啥不能这样写 const current= obj.getAny(path) as any;
//会报错‌error: java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Any‌
//不写却没事
const current= obj.getAny(path);
// 返回最终的值
return current;
}
return null;
}

2025-03-17 18:07 负责人:无 分享
已邀请:

要回复问题请先登录注册