我要在這裏做出反應路由器代碼:modal-galleryJavaScript語法反應路線
和跨越這句法
const Modal = ({ match, history }) => {
const image = IMAGES[parseInt(match.params.id, 10)]
if (!image) {
return null
}
const back = (e) => {
e.stopPropagation()
history.goBack()
}
return (
<div
onClick={back}
style={{
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
background: 'rgba(0, 0, 0, 0.15)'
}}
>
<div className='modal' style={{
position: 'absolute',
background: '#fff',
top: 25,
left: '10%',
right: '10%',
padding: 15,
border: '2px solid #444'
}}>
<h1>{image.title}</h1>
<Image color={image.color} />
<button type='button' onClick={back}>
Close
</button>
</div>
</div>
)
}
我的問題是,什麼樣的語法是這樣來的?並且如何將其轉換爲ES6 React.Component class
這就是所謂的解構賦值。 – Li357
請注意,這不是JavaScript;並且可能還需要使用[tag:jsx]添加標籤(即使您最終要詢問的現象在JavaScript和JSX中都可用)。 – Amadan