首页 > 解决方案 > 我想从我的 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}

标签: reactjsreact-native

解决方案


您可以像在componentDidMount函数中那样引用它:

{this.state.description}

推荐阅读