繁体   English   中英

反应:{-} 未定义 no-undef

[英]React : {-} is not defined no-undef

错误是 -
第 16:18 行:“用户名”未定义 no-undef

第 20:18 行:'imageUrl' 未定义 no-undef

第 22:49 行:“用户名”未定义 no-undef

第 22:76 行:'caption' 未定义 no-undef

<Post username="elitorbi" caption="something in here" imageUrl="https://static.toiimg.com/thumb/msid-67586673,width-800,height-600,resizemode-75,imgsize-3918697,pt-32,y_pad-40/67586673.jpg"/>
  
<Post username="elitorbi" caption= "this is a caption" imageUrl="https://i.guim.co.uk/img/media/fe1e34da640c5c56ed16f76ce6f994fa9343d09d/0_174_3408_2046/master/3408.jpgwidth=1200&height=900&quality=85&auto=format&fit=crop&s=0d3f33fb6aa6e0154b7713a00454c83d"/>

==================================================== ===============

import React, {useState} from 'react'
import './post.css'
import './App.js'
import Avatar from "@material-ui/core/Avatar"


function Post() {
    return (
        <div className="post">
            <div className="post__header">
            <Avatar
                className="post__avatar"
                alt= 'elitorbi'
                src="/static/images/avatar/1.jpg"
            ></Avatar>
            <h3>**{username}**</h3>
            </div>
            <img
            className = "post__image" 
            src={imageUrl} />
            
            <h4 className="post__text"><strong>{username}</strong><n> </n>{caption}</h4>
        </div>
    )
}

export default Post

您应该使用组件的props

function Post(props) {
  const { username, imageUrl, caption } = props;
  return ...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM