我正在学习react技术,我是第一个必须像这样放置图像的练习,但是当我使用map函数来放置图像时,我没有看到图像:/
import React from 'react'<br>
import './Style/App.css'
const tabImg = ['./img/html.png', './img/css.png', './img/javascript.png', './img/logo192.png']<br>
const displayImgTech = tabImg.map((tech) => <img key={tech} src={tech} alt="techno"/>)<br>
export const Header = () => {
return (
<div className='container'>
<img src={displayImgTech} alt='technoFE'/>
</div>
)
}谢谢
发布于 2021-04-07 01:27:51
通过在src img props中传递displayImgTech,您添加的不是一个url,而是一个img标记的“数组”。所以你只需要像这样在你的div中调用{display take:
const displayImgTech = tabImg.map((tech) => <img key={tech} src={tech} alt="techno"/>)<br>
export const Header = () => {
return (
<div className='container'>
{displayImgTech}
</div>
)
}
https://stackoverflow.com/questions/66971812
复制相似问题