【发布时间】:2017-06-17 18:23:46
【问题描述】:
我已将图像插入数据库,并且我正在从数据库接收图像到服务器和 reactjs,但在我的反应中我收到它有二进制数据。 但是我如何在反应中将二进制数据转换为图像。
class Pre extends React.Component{
constructor(props){
super(props);
this.state={
post:[]
};
}
componentDidMount(){
let self = this;
axios.get('http://localhost:8080/images')
.then(function(data) {
//console.log(data);
self.setState({post:data.data});
});
}
render(){
console.log(this.state.post);
return(
<div className="w3-container">
<p className="addboard"> <Link className="linkpre" to="/createstudent I">
<button className="addbutton" type="button"><h1>+</h1></button></Link></p>
{this.state.post}
)}
)}
</div>
);
}
}
export default Pre;
【问题讨论】:
标签: javascript reactjs