Search code examples
htmlvue.jsvuejs2reload

How to reload/refresh a webpage in Vue.js after a certain event or a button is clicked?


I want to reload a webpage just once everytime after pressing a button on the webpage. I have written my code in Vue.js. How do I achieve this?

Note: I do not want to auto-refresh after specific interval of time. Instead just once after everytime that button on the webpage is clicked.

I would appreciate any help given. Thank you.


Solution

  • Just use window.location.reload().

    <template>
      <button @click="reloadPage">Reload</button>
    </template>
    
    
    <script>
    export default {
      ...
      methods: {
        reloadPage() {
          window.location.reload();
        }
      }
    }
    </script>