Javascript jsx中的img src属性url

Javascript jsx中的img src属性url,javascript,reactjs,jsx,Javascript,Reactjs,Jsx,我试图显示数组中的图像,但当我将src值作为表达式{}传递时,它只是以对象的形式而不是字符串的形式返回。有人能解释一下吗 export default class Home extends Component{ constructor(){ super(); this.state = {}; } componentWillMount(){ var url = "https://api.github.com/users";

我试图显示数组中的图像,但当我将src值作为表达式{}传递时,它只是以对象的形式而不是字符串的形式返回。有人能解释一下吗

export default class Home extends Component{
    constructor(){
        super();
        this.state = {};
    }
    componentWillMount(){
        var url = "https://api.github.com/users";
        request.get(url).then((response) => {
            this.setState({
                users: response.body
            });
        });
    }
    render(){ 
        // this.state.users returns all users information (name, image...)
        const userName = _.map(this.state.users, (user) =>{
            return <li>{user.login}</li>
        });
        const repoURL = _.map(this.state.users, (repoUrl) =>{
            return <li>{repoUrl.repos_url}</li>
        });

        const eachAvatar = _.map(this.state.users, (avatar) =>{
            return <li>{avatar.avatar_url}</li>
        });

        return(
        <div>
        <h2>Here is the list of users in gitHub</h2>
        <table>
        <tr>
        <th>UserName</th>
        <th>Repo URL</th>
        </tr>
        <tr>
        <td>{userName}</td>
        <td>{repoURL}</td>
        <td><img  src={eachAvatar} /></td>
        </tr>
        </table>
        </div>
    );
    }
}
导出默认类主扩展组件{
构造函数(){
超级();
this.state={};
}
组件willmount(){
变量url=”https://api.github.com/users";
request.get(url).then((响应)=>{
这是我的国家({
用户:response.body
});
});
}
render(){
//this.state.users返回所有用户信息(名称、图像…)
const userName=\.map(this.state.users,(user)=>{
返回
  • {user.login}
  • }); const repoorl=u551;.map(this.state.users,(repoorl)=>{ return
  • {repoUrl.repos\uURL}
  • }); const eachAvatar=uu.map(this.state.users,(avatar)=>{ 返回
  • {avatar.avatar\u url}
  • }); 返回( 下面是gitHub中的用户列表 用户名 回购网址 {userName} {repoURL} ); } }
    输出:


    我猜您想要一个图像列表,因此在地图中呈现
    img
    标记:

    const allAvatars = _.map(this.state.users, (avatar) =>{
                return <li><img src={avatar.avatar_url} /></li>
            });
    
    const allAvatars=\uu.map(this.state.users,(avatar)=>{
    返回
  • });
    然后渲染所有化身

    <td>{allAvatars}</td>
    
    {allAvatars}
    
    您不能让
    src
    属性是一堆列表项!