英文:
Problem with SVG: Error: Can't resolve '../../assets/logo.svg' in '/Users/ricaldito/Desktop/gpt3_jsm/src/components/navbar'
问题
I tried to modify the '../../assets/logo.svg'; but it doesnt change at all.
英文:
import React from 'react';
import { RiMenu3Line, RiCloseline } from 'react-icons/ri';
import logo from '../../assets/logo.svg';
import './navbar.css';
function Navbar() {
return (
<div className="gpt3__navbar">
<div className="gpt3__navbar-links">
<div className="gpt3__navbar-links_logo">
<img src={logo} alt="logo" />
</div>
</div>
</div>
)
}
export default Navbar
I tried to modify the '../../assets/logo.svg'; but it doesnt change at all.
答案1
得分: 1
将logo.svg
文件放入你的public
文件夹,然后将它作为<img />
标签的src
属性添加,就像这样:
<img src={`/asset/logo.svg`} alt=""/>
你不需要在你的React代码中导入logo.svg
,所以你可以移除以下行:
import logo from '../../assets/logo.svg';
英文:
Put the logo.svg
file in your public
folder, then add it as a src
attribute in your <img />
tag, like so:
<img src={`/asset/logo.svg`} alt=""/>
You do not need to import logo.svg
in your React code, so you can remove the following line:
import logo from '../../assets/logo.svg';
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论