[英]Cache Image in react.js then image not appearing
I was planning to upload my React.js website into GitHub.我打算将我的 React.js 网站上传到 GitHub。 then I enter npm cache clean --force into the terminal and then now all my image is in cache image.
然后我在终端中输入 npm cache clean --force ,然后现在我的所有图像都在缓存图像中。 none of my images is loading up but the other information and animation are still working.
我的图像都没有加载,但其他信息和动画仍在工作。 how do I fix this problem?
我该如何解决这个问题? thanks
谢谢
the images is under className='navbar-container container location.图像在 className='navbar-container 容器位置下。
import React, { useState, useEffect } from 'react'
import {Link} from 'react-router-dom'
import {FaBars, FaTimes} from 'react-icons/fa'
import { Button } from './Button'
import './Navbar.css'
import {IconContext} from 'react-icons/lib'
function Navbar() {
const [click,setClick]= useState(false);
const [button,setButton]= useState(true)
const handleClick = () => setClick(!click);
const closeMobileMenu = () => setClick(false)
const showButton = () => {
if (window.innerWidth <= 960){
setButton(false)
} else {
setButton(true)
}
};
useEffect(() => {
showButton();
}, []);
window.addEventListener('resize',showButton);
return (
<>
<IconContext.Provider value ={{color: "#fff"}}>
<nav className='navbar'>
<div className='navbar-container container'>
<Link to='/' className='navbar-logo' onClick={closeMobileMenu}>
<img src="/images/UOWMKDU-logb.png"
alt="UOWKDU Logo" width="35%" height="85%" className='navbar-icon' />
</Link>
<div className='menu-icon' onClick={handleClick}>
{click ? <FaTimes /> : <FaBars />}
</div>
<ul className={click ? 'nav-menu active' : 'nav-menu'}>
<li className='nav-item'>
<Link to='/' className='nav-links' onClick={closeMobileMenu}>
Home
</Link>
</li>
<li className='nav-item'>
<Link
to='/service'
className='nav-links'
onClick={closeMobileMenu}
>
Services
</Link>
</li>
<li className='nav-btn'>
{button ? (
<Link to='/sign-up' className='btn-link'>
<Button buttonStyle='btn--outline' >SIGN UP</Button>
</Link>
) : (
<Link to='/sign-up' className='btn-link' onClick={closeMobileMenu}>
<Button
buttonStyle='btn--outline'
buttonSize='btn--mobile'
>
SIGN UP
</Button>
</Link>
)}
</li>
</ul>
</div>
</nav>
</IconContext.Provider>
</>
)
}
export default Navbar
Fixed:固定的:
I recreate an new react.js folder and copy and paste the old one to the new one.我重新创建了一个新的 react.js 文件夹,然后将旧文件夹复制并粘贴到新文件夹中。 because of packages.json have some issues.
因为packages.json 有一些问题。 i think it might be some packages missing.
我想这可能是缺少一些包。 but after make a new react.js file and copy and paste back.
但是在创建一个新的 react.js 文件并复制并粘贴回来之后。 everything is fine
一切安好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.