原生JS
1、window.history.go(0)方法
window.history.go(0)2、location.reload()方法
location.reload()3、location.href=location.href方法
location.href=location.hrefvue
4、vue-router方法
const router = useRouter()
router.go(0)react
5、react-router方法
import { createBrowserHistory, createHashHistory } from 'history';
const history = createBrowserHistory() // history模式
const history = createHashHistory() // hash模式
history.go(0)

本文介绍了在JavaScript中如何使用window.history.go(0)、location.reload()和location.href=location.href来刷新页面。同时,针对Vue和React应用,展示了如何利用vue-router和react-router的go方法以及history对象的创建和使用,实现页面导航和回退。
8万+

被折叠的 条评论
为什么被折叠?



