我只是无法理解这一点,我想,我可能已经尝试了6次,总是求助于 any
... ... 有没有一种合法的方法可以从一个 HTML 元素开始,把它包装在一个组件中,然后再把它包装到另一个组件中,这样 HTML 道具就可以遍历所有内容?本质上定制 HTML 元素?例如:
interface MyButtonProps extends React.HTMLProps<HTMLButtonElement> {}
class MyButton extends React.Component<MyButtonProps, {}> {
render() {
return <button/>;
}
}
interface MyAwesomeButtonProps extends MyButtonProps {}
class MyAwesomeButton extends React.Component<MyAwesomeButtonProps, {}> {
render() {
return <MyButton/>;
}
}
用法:
<MyAwesomeButton onClick={...}/>
Whenever I attempt this sort of composition, I get an error similar to:
Foo 的“ ref”属性不能分配给目标属性。