
前端刷新页面的五种方法(含原生js、vue和react)
3、location.href=location.href方法。2、location.reload()方法。5、react-router方法。4、vue-router方法。
·
原生JS
1、window.history.go(0)方法
window.history.go(0)
2、location.reload()方法
location.reload()
3、location.href=location.href方法
location.href=location.href
vue
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)
更多推荐
所有评论(0)