代码之家  ›  专栏  ›  技术社区  ›  LAGIM

函数无法读取

  •  -1
  • LAGIM  · 技术社区  · 9 年前

    为什么baseApi不能在渲染中读取我尝试了一切,但它不起作用我尝试了道具和状态,但也不起作用

    componentDidMount() {
            let baseApi = this.props.lenk('files/');
            this.baseApi(baseApi);
        }
    
     baseApi(link){
                return link;
            }
    
        renderImage(i,d) {
                debugger
    
                var Link= i.Link;
                var file = i.Name;
                let baseApi =this.baseApi();
    }
    

    1 回复  |  直到 9 年前
        1
  •  0
  •   Farzam Babar    9 年前

    constructor() {
     super();
     this.renderImage= this.renderImage.bind(this);
     //this.baseApi= this.baseApi.bind(this);
    }
    

    在使用渲染的地方,如果在渲染中,则循环函数可能不适用于此逻辑。应该试试

    componentWillMount() //instead of componentDidMount