【发布时间】:2021-04-23 09:43:57
【问题描述】:
我想做的是将宽度、高度和样式属性导入反应组件。我将首先显示带有对象属性的 .json 文档:
"manufacturerData": {
"name": "Duesenberg",
"articleCount": 0,
"image": {
"file": "duesenberg.jpg",
"width": "140",
"height": "52",
"exists": true
}
},
我想将样式:width 和 height 导入到我的图片卡片容器中,如下所示:
return (
<Card className='my-3 p-3 thumbnail' style={{ width: '14rem' }}>
<a href={`/articles/${articles.id}`}>
<Card.Img src={`/images/${articles.image.file}`} variat='top' />
</a>
</Card>
)
我似乎无法在网上找到任何关于如何完成这项工作的直接说明。 非常感谢您的帮助。
【问题讨论】:
-
谢谢你,克里斯,它工作得很好,路径让我感到困惑,但你是对的。
标签: javascript html css reactjs