Reactjs 未找到模块:Can';t解决';//图片/果冻';在';C:\Users\MSI\Desktop\cake-app\src\Components\Product';
请有人帮我修复此错误。我不明白错误的原因Reactjs 未找到模块:Can';t解决';//图片/果冻';在';C:\Users\MSI\Desktop\cake-app\src\Components\Product';,reactjs,svg,webpack,components,babeljs,Reactjs,Svg,Webpack,Components,Babeljs,请有人帮我修复此错误。我不明白错误的原因 import React from 'react' import styled from 'styled-components' import CustomButton from "../CustomButton/CustomButton"; import logo from "../../images/jelly"; // svg icon // I also tried this method but I
import React from 'react'
import styled from 'styled-components'
import CustomButton from "../CustomButton/CustomButton";
import logo from "../../images/jelly"; // svg icon
// I also tried this method but I got the same error
// import { ReactComponent as Logo } from "../../images/jelly";
const Product = () => {
return (
<Wrapper>
<img src={logo} alt="logo" />
{/* <Logo></Logo> */}
<div className="content">
<h4>Chocolate</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
</div>
<CustomButton>$20 | Order Now </CustomButton>
</Wrapper>
)
}
export default Product
const Wrapper = styled.div``
从“React”导入React
从“样式化组件”导入样式化
从“./CustomButton/CustomButton”导入CustomButton;
从“../../images/jelly”//svg图标
//我也尝试过这种方法,但我得到了同样的错误
//从“../../images/jelly”导入{ReactComponent as Logo};
常数乘积=()=>{
返回(
{/* */}
巧克力
我的同僚们都是精英
20美元|立即订购
)
}
导出默认产品
const Wrapper=styled.div``
您需要在文件名中添加.svg:
从“./../images/jelly.svg”导入徽标代码>谢谢。它工作正常:)