问题描述 graphRef.current?.zoom(0.9) graphRef.current可能是undefind,用可选链调用zoom方法,结果ts报错TS2722: Cannot invoke an object which is possibly 'undefined'.,百度了半天也没找到答案,在此记录一下问题解决方法。 解决方法 graphRef.current?.zoom!(0.9) zoom方法后面加上!就行了