代码:
//button
<button class="btn back p-cu-p" @click="goback">GoBack</button>
//function
goback () {
this.$router.go(-1)
},
//route
{
path: '/certification',
name: 'CertifictionIndex',
component: () => import('@/views/CustomerManagement/certificationIndex.vue'),
children: [
{
path: '/',
name: 'Certifiction',
component: () => import('@/views/CustomerManagement/certification.vue'),
},
{
path: 'detail',
name: 'CertifictionDetail',
component: () => import('@/views/CustomerManagement/certificationDetail.vue'),
},
],
}
路由栈中存在两条以上路由记录
用 this.$router.push(‘path’)可以正常跳转 ,但this.$router.go(-1)无法正常返回上一条路由
将button 改为其它标签
那你有放 0试试嘛
go(0)只是刷新当前路由 ,试过 window.history.back() 、window.history.go(-1)都有这个问题
用 this.$router.push(‘path’)可以正常跳转 ,但this.$router.go(-1)无法正常返回上一条路由
给 <button>
加个 type="button"
属性,不然默认情况下是提交按钮,触发表单提交了
<button class="btn back p-cu-p" @click="goback" type="button">GoBack</button>