【问题标题】:React dynamics image反应动力学图像
【发布时间】:2021-07-02 10:10:49
【问题描述】:

我正在学习反应技术,我是第一个练习,我必须像这样放置图像,但是当我使用地图功能放置图像时,我没有看到图像:/

image dynamics example

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>
        )
}

谢谢

【问题讨论】:

    标签: javascript reactjs web frontend reactjs.net


    【解决方案1】:

    通过在 src img 道具中传递 displayImgTech,您不是在添加 url,而是添加了 img 标签的“数组”。所以你只需要像这样调用 {display take in your div:

    const displayImgTech = tabImg.map((tech) => <img key={tech} src={tech}  alt="techno"/>)<br>
    
    export const Header = () => {
            return (
                <div className='container'>
                   {displayImgTech} 
                </div>
            )
    }
    

    【讨论】:

    • 非常感谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-26
    • 2012-04-22
    • 2022-11-22
    • 1970-01-01
    相关资源
    最近更新 更多