1
私はデータベースに画像を挿入しても、私はデータベースからサーバとreactjsに画像を受信していますが、私はそれがバイナリデータを受信しています。 しかし、どのようにして私はバイナリデータを反応してイメージに変換しますか?どのようにreactjsの画像にバイナリデータを変換する
あなたがバイナリデータを持っている場合、このような画像に変換し、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;