在Vue 2中,你可以使用location.reload()
方法来刷新页面。你可以将这个方法与按钮的点击事件绑定,以实现点击按钮时刷新页面的效果。
示例:
<template>
<div>
<button @click="refreshPage">刷新页面</button>
</div>
</template>
<script>
export default {
methods: {
refreshPage() {
location.reload();
}
}
}
</script>
在上面的代码中,我们定义了一个按钮,当按钮被点击时,会调用refreshPage
方法。该方法内部使用location.reload()
来刷新页面。这种方法会重新加载整个页面,并清除当前页面的所有状态。