Reactjs 如何获得一些文章的详细概述
从“React”导入React; 从“axios”导入axios 从“antd”导入{Card} 类ArticleDetail扩展了React.Component{Reactjs 如何获得一些文章的详细概述,reactjs,django,Reactjs,Django,从“React”导入React; 从“axios”导入axios 从“antd”导入{Card} 类ArticleDetail扩展了React.Component{ state = { article: {} } componentDidMount() { const articleID = this.props.match.params.articleID; axios.get(`http://127.0.0.1:8000/api/${articleID}`)
state = {
article: {}
}
componentDidMount() {
const articleID = this.props.match.params.articleID;
axios.get(`http://127.0.0.1:8000/api/${articleID}`)
.then(res => {
this.setState({
article: res.data
});
})
}
render() {
return (
<div>
<Card title={this.state.article.title}>
<p>{this.state.article.content}</p>
</Card>
</div>
)
}
状态={
第条:{}
}
componentDidMount(){
const articleID=this.props.match.params.articleID;
axios.get(`http://127.0.0.1:8000/api/${articleID}`)
。然后(res=>{
这是我的国家({
第条:物数据
});
})
}
render(){
返回(
{this.state.article.content}
)
}
}
导出默认的详细信息 你能不能提供更详细的问题,关于你想做什么,你遇到了什么障碍?这和Django有关系吗?这是什么意思“一些文章的详细概述”?Thanks@M-陈-3
//Make sure on your article.js file under title link you use ` instead of '
<List.Item.Meta
avatar={<Avatar src={item.avatar} />}
title={<a href={`/${item.id}`}>{item.title}</a>} //here
description={item.description}
/>
{item.content}
</List.Item>`
exact path='/:articleID' component={ArticleDetail}