Nodejs 서버에서 bindata를 수신하고 있습니다. 이제 이미지를 표시해야합니다. 이것을 어떻게 할 수 있습니까? JPEG 또는 다른 형식으로 bindata를 변환 할 수있는 방법이 있습니까? 또는 서버에서 변환 한 다음 해당 이미지를 보내면 반응 할 수 있습니까?React에서 이미지를 표시하는 방법?
이 내 반응 코드입니다 :
componentDidMount(){
let self = this;
axios.get('http://localhost:8080/list')
.then(function(data) {
console.log(data);
self.setState({post:data.data});
});
}
<ul className="w3-ul w3-card-4 w3-light-grey"> {this.state.post.map((item, index)=> {
return (
<Link to="/displaylist" style={{textDecoration:'none'}} key={index} >
<li className=" w3-hover-green w3-padding-16" onClick={this.handleClick(item.Id)}>
<img src={item.Image.data.data} className="w3-left w3-circle w3-margin-right " width="60px" height="40px" />
<span>{item.Firstname}</span><br/><br/>
</li>
</Link>
)}
)}
</ul>
이 내 nodejs의 코드 :
server.get('/list', function(req, res) {
databaseInterface.listStudent(function(err, students) {
var myJSON = students;
res.json(myJSON);
//You should see the newly saved student here
});
});
당신이 당신의 이미지를 의미가 base64로 문자열 형식으로되어? –
네, 일련의 문자를 좋아합니다. –
그 방법을 알고 있습니까? –