使用了ant-design样式框架
取到的数据header是200状态码 ,respond也有数据,就是页面没有效果
fetch部分:
componentWillMount(){
var myFetchOptions={
method :'GET'
};
fetch("http://v.juhe.cn/toutiao/index?type="+this.props.type +
"&key=46e7985e9edd9368dde9136c8fae6", myFetchOptions)
.then(response => response.json())
.then(responseJson => this.setState({news:responseJson}));
};
construtor函数:
constructor(){
super();
this.state={
news:''
}
};
response中的数据:
数据的渲染:
news.result.data.map((newsItem,index)=>(
<div key={index} class="imageblock">
<Link to={'details/${newsItem.uniquekey}'} target="_blank">
<div class="custom-image">
<img alt="" style={styleImage} src={newsItem.thumbnail_pic_s} />
</div>
<div class="custom-card">
<h3 style={styleH3}>{newsItem.title}</h3>
<p>{newsItem.author_name}</p>
</div>
</Link>
</div>
))
constructor
中的news
初始化类型有误,应该是个空数组[]
而不是空字符串''
,如果是空字符串的话,第一次渲染时news.result.data.map
会报错,所以你的页面是个空白页