Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

react怎么调用class类组件里面的某个函数?

在某个class类组件里面有一个方法,其他的组件中也需要,粘贴复制太low了,并且大大增加代码量,我想用导入导出的方法拿取到里面的方法,有大佬能告诉我吗


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

可以把这个方法放到class上面用export导出,但是这样肯定不妥。 你应该把这个方法单独放到一个js文件里再分别导入。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...