Fra*_*cis 1 javascript reactjs arrow-functions slate
我不明白这在javascript中是如何工作的
renderMarkButton(type, icon) {
Run Code Online (Sandbox Code Playgroud)
它看起来像一个箭头功能,但没有箭头.这是上下文:
class HoverMenu extends React.Component {
renderMarkButton(type, icon) {
const { editor } = this.props
return (
<div className="editorButton"
onMouseDown={event => this.onClickMark(event, type)}>
<FontAwesomeIcon color="#666" active={isActive}
className="editorButton" icon={icon} />
</div>
)
}
render() {
return (
<div>
{this.renderMarkButton('bold', {...faBold})}
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
我也很困惑
const { editor } = this.props
Run Code Online (Sandbox Code Playgroud)
我相信它来自Slate.我希望this.props在这种情况下是{type,icon}.
关于你的问题:
renderMarkButton(type, icon) {只是es6类语法:https:
//developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classesconst { editor } = this.props被称为"解构".你可以在这里阅读:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment希望有帮助:)
| 归档时间: |
|
| 查看次数: |
129 次 |
| 最近记录: |