Module not found: Error: Can't resolve './NewsItem' in 'C:\Users\Admin\Downloads\js\newsapp\src\components'
ERROR in ./src/components/News.js 6:0-34
Module not found: Error: Can't resolve './NewsItem' in 'C:\Users\Admin\Downloads\js\newsapp\src\components'
代码:
import React from 'react'
const NewsItem = (props)=> {
let { title, description, imageUrl, newsUrl, author, date, source } = props;
return (
<div className="my-3">
<div className="card">
<div style={{
display: 'flex',
justifyContent: 'flex-end',
position: 'absolute',
right: '0'
}
}>
<span className="badge rounded-pill bg-danger"> {source} </span>
</div>
<img src={!imageUrl ? "https://fdn.gsmarena.com/imgroot/news/21/08/xiaomi-smart-home-india-annoucnements/-476x249w4/gsmarena_00.jpg" : imageUrl} className="card-img-top" alt="..." />
<div className="card-body">
<h5 className="card-title">{title} </h5>
<p className="card-text">{description}</p>
<p className="card-text"><small className="text-muted">By {!author ? "Unknown" : author} on {new Date(date).toGMTString()}</small></p>
<a rel="noreferrer" href={newsUrl} target="_blank" className="btn btn-sm btn-dark">Read More</a>
</div>
</div>
</div>
)
}
export default NewsItem
import React from 'react'
const NewsItem = (props)=> {
let { title, description, imageUrl, newsUrl, author, date, source } = props;
return (
<div className="my-3">
<div className="card">
<div style={{
display: 'flex',
justifyContent: 'flex-end',
position: 'absolute',
right: '0'
}
}>
<span className="badge rounded-pill bg-danger"> {source} </span>
</div>
<img src={!imageUrl ? "https://fdn.gsmarena.com/imgroot/news/21/08/xiaomi-smart-home-india-annoucnements/-476x249w4/gsmarena_00.jpg" : imageUrl} className="card-img-top" alt="..." />
<div className="card-body">
<h5 className="card-title">{title} </h5>
<p className="card-text">{description}</p>
<p className="card-text"><small className="text-muted">By {!author ? "Unknown" : author} on {new Date(date).toGMTString()}</small></p>
<a rel="noreferrer" href={newsUrl} target="_blank" className="btn btn-sm btn-dark">Read More</a>
</div>
</div>
</div>
)
}
export default NewsItem
1条答案
按热度按时间euoag5mw1#
您必须将
NewsItem.js
组件导入到News.js
组件中才能使用它。