Javascript 导入阵列中的图像

Javascript 导入阵列中的图像,javascript,reactjs,Javascript,Reactjs,我尝试在React中导入数组中的图像,但图像未显示。如果我想单独展示它们,一切都可以 import ich from '../car.jpg'; import mauri from '../mauri.png'; export class Home extends React.Component { constructor() { super(); this.state = { checked: false, bilder: [{car},{mauri}] };

我尝试在React中导入数组中的图像,但图像未显示。如果我想单独展示它们,一切都可以

import ich from '../car.jpg';
import mauri from '../mauri.png';

export class Home extends React.Component {
 constructor() {
 super();
 this.state = {
    checked: false,
    bilder: [{car},{mauri}]
    };
   this.handleChange = this.handleChange.bind(this);
  }

  [...]
    <Row>
    {this.state.bilder.map((bild,i) =>        
      <Col xs={4} md={3} lg={3} key={i}>
          <Image src={bild} key={i} thumbnail />
      </Col>
    )}
    </Row>
您可以阅读如何正确使用所需图像:

 this.state = {
    checked: false,
    bilder: ["../car.jpg", "../mauri.png"]
    };
   this.handleChange = this.handleChange.bind(this);
  }
对于组件:

    <Row>
    {this.state.bilder.map((bild,i) =>        
      <Col xs={4} md={3} lg={3} key={i}>
          <Image src={require(bild)} key={i} thumbnail />
      </Col>
    )}
    </Row>
将bilder:[{car},{mauri}]更改为bilder:[car,mauri]

状态={ 勾选:假, 比尔德:[汽车,莫里] }; ... {this.state.bilder.mapbild,i=> } 此外,请查看以下示例: