接口定义打字稿方法参数问题?
用ts
定义了一种方法。根据条件,回调方法中的参数顺序为a
,b
或b
,a
。
if (props.xxx) {
props.onChange(a, b)
} else {
props.onChange(b, a)
}
接口中应该如何描述这种onchange方法?
A method is defined with ts
. According to the conditions, the order of parameters in the callback method is a
, b
, or b
, a
.
if (props.xxx) {
props.onChange(a, b)
} else {
props.onChange(b, a)
}
How should this onChange method be described in the interface?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是使用功能过载,而是使用联合类型:
Instead of using function overloading, use union types: