Vue2 clicks the button to refresh the page and clear all the page numbers

In Vue 2, you can use location.reload()method to refresh the page. You can bind this method to the click event of the button to achieve the effect of refreshing the page when the button is clicked.

Example:

<template>
  <div>
    <button @click="refreshPage">刷新页面</button>
  </div>
</template>

<script>
export default {
  methods: {
    refreshPage() {
      location.reload();
    }
  }
}
</script>

In the above code, we defined a button, and when the button is clicked, refreshPagethe method will be called. This method is used internally location.reload()to refresh the page. This method reloads the entire page and clears all state for the current page.

おすすめ

転載: blog.csdn.net/m0_53286358/article/details/131899484