- How to use
location.reload()
:
In Vue components, you can location.reload()
refresh the entire page by calling a method.
javascript
copy
methods: {
refreshPage() {
location.reload(); // 刷新整个页面
}
}
- Ways to use Vue Router
router.go()
:
If you are using Vue Router in your Vue application, you can use router.go(0)
method to do page refresh.
javascript
copy
import { createRouter, createWebHistory } from 'vue-router';
const router = createRouter({
history: createWebHistory(),
routes: [
// your routes
]
});
methods: {
refreshPage() {
this.$router.go(0); // 刷新页面
}
}
- How to use
window.location.reload()
:
In Vue components, you can also use window.location.reload()
methods to refresh the entire page.
javascript
copy
methods: {
refreshPage() {
window.location.reload(); // 刷新整个页面
}
}
The above method can refresh the entire page. Please choose the appropriate method to refresh the Vue page according to your specific needs.