【问题标题】:How to get a detailed overview of some articles如何获得一些文章的详细概述
【发布时间】:2020-11-30 11:00:49
【问题描述】:

从“反应”导入反应; 从'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}`)
        .then(res => {
            this.setState({
                article: res.data
            });
            
        })
}


render() {
    return (
        <div>
            <Card title={this.state.article.title}>
            <p>{this.state.article.content}</p>
            </Card>
        </div>            
    )
}

}

导出默认 ArticleDetail;

【问题讨论】:

  • 您能否提供更详细的问题,说明您想做什么以及遇到什么障碍?
  • 这和 Django 有关系吗?
  • “部分文章的详细概述”是什么意思?

标签: reactjs django


【解决方案1】:
//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>`

//在你的 routes.js 文件下确保(文章 ID)与你在 Article-detail-view 上使用的相同

     exact path='/:articleID' component={ArticleDetail}

【讨论】:

  • 谢谢@M-Chen-3
猜你喜欢
  • 2022-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-26
  • 1970-01-01
  • 2020-03-26
  • 2015-07-31
相关资源
最近更新 更多