//方法一(短路逻辑,如果this.result为null或undefined,则取空对象{}作为默认值)
let data = (this.result || {}).data || {};
//方法二(条件判断)
if (obj && obj.method1 && obj.method1().method2) {
// 执行链式调用
}
//方法三(三元运算)
const result = obj && obj.method1 ? obj.method1().method2 : null;
//方法四(可选操作链)
const result = obj?.method1()?.method2;
//方法四(try/catch语句)
try {
// 执行链式调用
} catch (error) {
// 处理异常
}