我正试图在我正在制作的购物车中显示图像,但它没有显示出来.我必须导入每个图像吗?我知道我的路径很好,因为它之前有用.我认为我的product.js文件可能有问题,但我无法理解.
这是我的Product.js
import React, { Component, PropTypes } from 'react';
class Product extends Component {
handleClick = () => {
const { id, addToCart, removeFromCart, isInCart } = this.props;
if (isInCart) {
removeFromCart(id);
} else {
addToCart(id);
}
}
render() {
const { name, price, currency, image, url, isInCart } = this.props;
return (
<div className="product thumbnail">
<img src={image} alt="product" />
<div className="caption">
<h3>
<a href={url}>{name}</a>
</h3>
<div className="product__price">{price} {currency}</div>
<div className="product__button-wrap">
<button
className={isInCart ? 'btn btn-danger' : 'btn btn-primary'} …Run Code Online (Sandbox Code Playgroud)