我是靠谱客的博主 无辜乌龟,这篇文章主要介绍TS2722: Cannot invoke an object which is possibly ‘undefined‘.,现在分享给大家,希望可以做个参考。

问题描述

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方法后面加上!就行了

最后

以上就是无辜乌龟最近收集整理的关于TS2722: Cannot invoke an object which is possibly ‘undefined‘.的全部内容,更多相关TS2722:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(141)

评论列表共有 0 条评论

立即
投稿
返回
顶部