我有一个类似http://localhost:3000/artice/1140的链接,我想将artice / 1140传送到api:'http://demo4035073.mockable.io/'中。如何实现?
在类别组件中
<a href={`/artice/${data.id}`}>
详细信息组件
class Detail extends React.Component {
state = {
data: null
}
componentDidMount () {
const { handle } = this.props.match.params
const { fromNotifications } = this.props.location.state
fetch(`http://demo4035073.mockable.io/${handle}`)
.then((data) => {
this.setState(() => ({ data }))
})