我正在嘗試使用 Material UI 在我的 Next js 專案中顯示影像:
<Box display="flex" alignItems="center">
<Image
src={'/images/Profile.svg'}
alt={'Thumbnail-alt'}
width={300}
height={160}
style={{ background: '#252525e6', borderRadius: '6px' }}
/>
</Box>
但它所顯示的只是影像的 alt 標簽,而不是顯示實際影像。
我在這個專案中使用 Material UI 5 和 Nextjs 12。謝謝
uj5u.com熱心網友回復:
要加載靜態影像,首先匯入檔案。例如
import ProfileSvg from "/images/Profile.svg"
然后在你的影像中。
<Image
src={ProfileSvg}
alt={"Thumbnail-alt"}
width={300}
height={160}
style={{ background: "#252525e6", borderRadius: "6px" }}
/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/497133.html
