我目前正在开发一个电子商务网站我在这方面很新我想将一些图像导入我的页面时遇到了这个错误这是我的 productscreen.js
import React from "react";
import { Link } from "react-router-dom";
import { Row, Col, Image, ListGroup, Button, Card } from "react-bootstrap";
import Rating from "../components/Rating";
import products from "../products";
function ProductScreen({ match }) {
const product = products.find((p) => p._id === match.params._id)
return (
<div>
<Link to="/" className="btn btn-light my-3">
Go Back
</Link>
<Row>
<Col md={6}> if (!product) {
<Image src={product.image} alt={product.name} fluid />
}
</Col>
我解决了我的问题 const 代码在我的解决方案中应该是这样的。
function ProductScreen({ match }) {
const product = products.find((p) => p._id === match.params.id)
我必须在 _id 中删除我的 _ 感谢您的帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句