0
点赞
收藏
分享

微信扫一扫

学习记录:弹窗列表点击跳转详情,关闭详情如何判断回去哪个页面

腾讯优测 2022-02-17 阅读 57

A页面点击子项可以跳转到对应详情页面C,关闭详情页面C回到A页面,B页面点击子项也可以跳转到对应详情页面C,关闭详情页面回到B页面。关闭详情页面C回到A页面还是B页面需要跳转路由时query传参来区分:
A页面跳转方法如下,query传参中有from:‘list’

    toDetail(item) {
            if (item.firstCategoryId && item.firstCategoryId != '- -' && ['我对政府有话说', '随手拍'].includes(item.type)) {
                // && item.status != '1'
                this.$router.push({
                    path: '/smartCommunity/service/repairListFlow',
                    query: {
                        id: item.id,
                        firstCategoryId: item.firstCategoryId,
                        from: 'list'
                    }
                })
            } else {
                this.$router.push({
                    path: '/smartCommunity/service/repairListDetail',
                    query: {
                        id: item.id,
                        from: 'list'
                    }
                })
            }
        }

B页面写法与A页面一样,query传参中少了from选项
详情页面C需要再关闭方法中做判断:

closeDialog() {
            if (this.$route.query.from == 'list') {
                this.$router.go(-1)
            } else {
                this.$router.push('/smartCommunity/service')
            }
        },
举报

相关推荐

0 条评论