reactjs - 我想从我的 api 调用某个参数
问题描述
我无法从我的 api 调用某个参数
constructor(props) {
super(props);
this.state = {
news: [],
loading: true,
activeIndex: 0,
description: '',
}
}
componentDidMount() {
console.log(this.props);
let description = this.state.description;
let regex = /(<([^>]+)>)/gi;
let result = description.replace(regex, '');
this.setState({ description: result });
我在这样的代码中叫他
{item.description}
解决方案
您可以像在componentDidMount
函数中那样引用它:
{this.state.description}
推荐阅读
- python - 使用正则表达式排除匹配
- dns - 我可以在 DNS 中添加两条 TXT 记录吗
- r - 在 Shiny R 中,有没有办法在没有延迟的情况下立即运行 observeEvent(renderUI 问题)?
- java - 在 JpaRepository findAll() 方法中返回对象的浅表副本
- coq - 你如何在 Coq 中证明 (e: p = p) = eq_refl?
- elasticsearch - 检查 Elasticsearch 是否在过去 X 小时内运行,尽管没有文档被索引
- vba - 如何使用 Outlook 对象模型为单个出站电子邮件设置编码?
- python - 从图像中准确裁剪文档纸
- swift - webView中键盘输入时屏幕放大原样的问题
- unity3d - Unity中的多层纹理着色器