1. 程式人生 > >Vue.js重新整理當前頁面

Vue.js重新整理當前頁面

Vue.js的路由跳轉很強大,類似ajax的區域性重新整理,路由跳轉時候頁面是不重新整理的,重新整理當前頁面的功能不建議用,但是有的時候確實需要重新整理當前頁面來實現某些需求,這個時候,我們有兩種方法可以實現。

 

第一種就是傳統的的方法

window.location.reload();

 

第二種是通過vue.js的路由來實現

this.$router.go(0)

 

<template>
  <section>
    <h1 ref="hello">{{ value }}</h1
> <el-button type="danger" @click="get">點選</el-button> </section> </template> <script> export default { data() { return { value: 'Hello World ~' }; }, methods: { get() { this.$router.go(0); // window.location.reload();
} }, mounted() { }, created() { } } </script>

 

 

 

 

既然使用vue來做前端了,那麼這裡就推薦使用第二種方式吧~

 

嗯,就醬~~