原生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方法文章來源:http://www.zghlxwxcb.cn/news/detail-600871.html
const router = useRouter()
router.go(0)
react
5、react-router方法文章來源地址http://www.zghlxwxcb.cn/news/detail-600871.html
import { createBrowserHistory, createHashHistory } from 'history';
const history = createBrowserHistory() // history模式
const history = createHashHistory() // hash模式
history.go(0)
到了這里,關(guān)于前端刷新頁面的五種方法(含原生js、vue和react)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!