this.router.push(path)相当于点击路由链接(后退1步,会返回当前路由界面)this.router.push(path) 相当于点击路由链接(后退1步,会返回当前路由界面)
this.router.push(path)相当于点击路由链接(后退1步,会返回当前路由界面)this.router.replace(path) 用新路由替换当前路由(后退1步,不可返回到当前路由界面)
this.router.back()后退回上一个记录路由this.router.back() 后退回上一个记录路由
this.router.back()后退回上一个记录路由this.router.go(n) 参数 n 指定步数
this.router.go(−1)后退回上一个记录路由this.router.go(-1) 后退回上一个记录路由
this.router.go(−1)后退回上一个记录路由this.router.go(1) 向前进下一个记录路由
<ul >
<li v-for="(tech,index) in techArr" :key="tech.id">
<span>{{tech.title}}</span>
<button @click="pushTech(tech.id)" class="btn btn-default btn-xs">查看(Push)</button>
<button @click="replaceTech(tech.id)" class="btn btn-default btn-xs">查看(replace)</button>
</li>
<button @click="$router.back()">后退</button>
<button @click="$router.go(-1)">go后退</button>
<button @click="$router.go(1)">前进</button>
</ul>
pushTech(id){
this.$router.push(`/news/tech/detail/${id}`)
},
replaceTech(id){
this.$router.replace(`/news/tech/detail/${id}`)
},