我正在尝试在 reactjs 中渲染图像。我正在处理一个 URL 并将其存储在一个全局 var URL 中。我想在 img 标签 src 中使用填充的 URL:
我曾尝试执行以下操作,但没有奏效
<img
src={url}
style={{
marginTop: '1px',
marginLeft: '1px',
marginBottom: '1px',
}}
height="500"
alt=""
/>
我的元素检查显示以下内容:
<img src height="500" alt="" style="margin-top: 1px; margin-left: 1px; margin-bottom: 1px;">
var url = '';
export default function ImageGallery() {
const classes = useStyles()
getList()
return (
<div>
<Paper className={classes.root}>
<img
src={{url}}
style={{
marginTop: '1px',
marginLeft: '1px',
marginBottom: '1px',
}}
height="500"
alt=""
/>
<Link to={'/imageGalleryGrid'} style={{ textDecoration: 'none' }}>
<Button variant="contained" className={classes.button} style={{
marginTop: '1px',
marginLeft: '550px',
marginBottom: '70px',
}}>
Checkout Gallery
</Button>
</Link>
</Paper>
</div>
)
}
图像未显示:我在控制台中看到正在打印 URL。另外,我可以转到 URL 并查看图像。
慕的地6264312
相关分类