typescript 解构 怎么给类型?
这个类型要怎么写。。我知道解构重命名的写法,
const handleClick = ({item:rename}:{item:string}):void => {}
不重命名怎么写呢
回答
以下三种写法,可以参考:
typescript"> const handleMenuClick = ({item, key, keyPath}: {item: Object, key: string, keyPath:string}) => { }
const handleMenuClick = ({item, key, keyPath}: any) => { }
interface SomeObj { item: Object
key: string
keyPath:string
}
const handleMenuClick1 = ({item, key, keyPath}: SomeObj) => {
}
以上是 typescript 解构 怎么给类型? 的全部内容, 来源链接: utcz.com/a/68663.html