【发布时间】:2018-06-11 16:28:25
【问题描述】:
我正在构建我的第一个 GatsbyJS 项目,并有一个简单的页面,该页面根据用户单击的活动按钮(“currentPage”)呈现内容。活动按钮保持在组件状态。
该页面在除 IE11 之外的所有主要浏览器中都能正常工作。我想知道我是否需要一个 polyfill(或其他东西)才能让它工作?
感谢您提供任何信息!
// handler in parent component
handlePageChange (e) {
e.preventDefault()
this.setState({
currentPage: e.target.value
})
}
// render of parent component
render () {
return (
<div className={styles.clientsRightsContainer}>
<Buttons
a={{ label: 'Label A', onClick: this.handlePageChange, value: 'pageA' }}
b={{ label: 'Label B', onClick: this.handlePageChange, value: 'pageB' }}
/>
}
...
// handler gets passed down to child component Buttons via `a` and `b` props
const Buttons = ({ a, b }) => (
<div className={styles.container}>
<button onClick={a.onClick} value={a.value}>{a.label}</button>
<button onClick={a.onClick} value={b.value}>{b.label}</button>
</div>
)
export default Buttons
【问题讨论】:
-
你尝试绑定你的函数了吗?
-
是的,
handlePageChange函数绑定在父构造函数中
标签: reactjs internet-explorer-11 babeljs gatsby