将对象分配给变量时的只读变量

时间:2018-07-22 16:01:04

标签: javascript html reactjs

我有一个名为picture的变量,该变量采用缩略图作为图片的地址。我想将其用作我的weindaten.clusters <- skmeans(wendaten.tr, 5, method="genetic") 标签的kunden.cluster<- skmeans(test4, 5, method="genetic") 路径。我该如何完成?据我了解,React首先生成src,然后生成img,但是我的代码返回了render()

更新 我根据建议的注释更改了代码。我将状态加载到构造函数中,以便在其他所有操作之前先进行定义。但是现在它说componentDidMount()就是Cannot set property 'src' of null所在的地方

代码

picture" is read-only

渲染结果摘要

-->

更新 我根据建议的注释更改了代码。我将状态加载到构造函数中,以便在其他所有操作之前先进行定义。但是现在它说 constructor(props) { super(props); this.props.getVideos(); const picture = {}; this.props.getVideos(); if (this.props.videos == null) { console.log("It's null"); } else { const videos = this.props.videos.video.map(video => { <h5 key={video._id}>{video.thumbnail}</h5>; --> picture = video.thumbnail; }); } } componentDidMount() { console.log(picture); } 就是 <div className="explore"> <div className="row"> <div className="row__inner"> <div className="tile"> <div className="tile__media"> <img className="tile__img" id="thumbnail" src={picture} alt="" /> </div> <div className="tile__details"> <div className="tile__title"> <h5>Impact Dallas</h5> </div> </div> </div> 所在的地方

0 个答案:

没有答案
相关问题