单击特定事件或按钮后,如何 reload/refresh Vue.js 中的网页?
How to reload/refresh a webpage in Vue.js after a certain event or a button is clicked?
我想每次在网页上按下一个按钮后重新加载一次网页。我已经在 Vue.js 中编写了我的代码。我该如何实现?
注意:我不想在特定时间间隔后自动刷新。而不是每次单击网页上的该按钮后仅单击一次。
如有任何帮助,我将不胜感激。
谢谢。
只需使用window.location.reload()
。
<template>
<button @click="reloadPage">Reload</button>
</template>
<script>
export default {
...
methods: {
reloadPage() {
window.location.reload();
}
}
}
</script>
我想每次在网页上按下一个按钮后重新加载一次网页。我已经在 Vue.js 中编写了我的代码。我该如何实现?
注意:我不想在特定时间间隔后自动刷新。而不是每次单击网页上的该按钮后仅单击一次。
如有任何帮助,我将不胜感激。 谢谢。
只需使用window.location.reload()
。
<template>
<button @click="reloadPage">Reload</button>
</template>
<script>
export default {
...
methods: {
reloadPage() {
window.location.reload();
}
}
}
</script>