Problem with SVG: Error: Can't resolve '../../assets/logo.svg' in '/Users/ricaldito/Desktop/gpt3_jsm/src/components/navbar'

huangapple go评论61阅读模式
英文:

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';

huangapple
  • 本文由 发表于 2023年2月8日 14:19:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75382008.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定