【发布时间】:2021-06-15 05:32:01
【问题描述】:
使用 create-react-app 和 tailwindcss 创建了一个应用。我正在尝试在我的网站中显示本地图像。我在 src 中创建了这个文件夹结构:assets/media/images/profile.jpg。图像不显示在浏览器中。这就是我正在做的事情。
这是src/components/Hero.js中的组件:
import ImageOne from '../assets/media/images/profile.jpg';
const Hero = () => {
return (
<div className="bg-white h-screen flex flex-col justify-center items-center">
<h1 className="lg:text-9xl md:text-7xl sm:text-5xl text-3xl font-black mb-14">
Text
</h1>
<img class="rounded" src={ImageOne} alt='Profile'/>
</div>
)
}
export default Hero
图像根本不显示。这是浏览器正在加载的内容:<img class="rounded" src="/static/media/profile.ba8339ef.jpg" alt="Profile">
其他 stackoberflow 答案,如 React won't load local images,对我没有帮助。
【问题讨论】:
标签: reactjs tailwind-css