Vue.js页面跳转后返回上一页面记录上一页面select选定的值

实现逻辑如下:

进入当前页面的时候,页面路由为http://localhost:8080/#/problem
点击某个标签,页面路径修改为http://localhost:8080/#/problem?index=3
index的值为选中的标签下标,这样就用当前路由记录了当前的标签选中项
进入详情页后,路由为http://localhost:8080/#/detail/?id=57
返回上级页面,页面路由为http://localhost:8080/#/problem?index=3
在页面渲染的时候,获取路由的参数,获取到index的值为3
然后就将标签的选中项,设置为下标为3的标签,
同时请求下标为3的标签项对应的问题内容,填充到右侧
代码如下:
给页面路由添加index内容

//在点击标签的时候调用
this.KaTeX parse error: Expected '}', got 'EOF' at end of input: … ...this.route.query,
index: index
}
})
1
2
3
4
5
6
7
// 判断路由中是否有index
if (this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …t index = this.route.query.index
// 设置标签的默认选中项
this.activeKey = index
// 获取选中项的右侧问题内容
let typeId = this.questionHeadData[index].typeId
this.oneId = typeId
this.getQuestionMore(typeId)
} else {
// 走正常的页面渲染逻辑
const typeId = this.questionHeadData[0].typeId
this.oneId = typeId
// 请求右侧数据
this.getQuestionMore(typeId)
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值