react-app中如何引用本地图片资源

版权声明:前端菜鸟--人间草木所有 https://blog.csdn.net/qq_43258252/article/details/87935305

方便你复制~~~

import React, { Component } from 'react'

// 引入图片  方法1
import imgs from '../../images/test.jpg'

class wordOfMouth extends Component {
  render() {
    return (
      <div className="wordOfMouth">
        wordOfMouth口碑
        <br />
        {/* 使用图片 方法1 */}
        <img alt="404" src={imgs} />
        {/* 使用图片 方法2 */}
        <img alt="404" src={require('../../images/test.jpg')} />
      </div>
    )
  }
}

export default wordOfMouth

猜你喜欢

转载自blog.csdn.net/qq_43258252/article/details/87935305