replace替换页面
<template>
<button @click="replacePage">替换页面</button>
</template>
<script>
export default {
methods: {
replacePage () {
// 注意:替换路由后,浏览器左键返回不到原来的页面
// path是跳转路径名称,query是需要传递的参数
this.$router.replace({ path: 'news', query: { id: 123 } })
}
}
}
</script>