vue 详情页返回列表页,保留列表页之前的筛选条件

1.设置cookie缓存

       //设置cookie
        Vue.prototype.setCookie = function (name, value, day) {
            if (day !== 0) {
                var expires = day * 24 * 60 * 60 * 1000;
                var date = new Date(+new Date() + expires);
                document.cookie = name + "=" + escape(JSON.stringify(value)) + ";expires=" + date.toUTCString();
            } else {
                document.cookie = name + "=" + + escape(JSON.stringify(value));
            }
        };
        //获取cookie
        Vue.prototype.getCookie = function (name) {
            var arr;
            var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return JSON.parse(unescape(arr[2]));
            else 
                return null
                };

在这里插入图片描述
2.判断是否从详情页过来

mounted() {
            //this.getData();
            console.log(this.options);
            if(this.$route.query.industryId){
                this.getData();
                this.formInline.i=this.$route.query.industryId;
                this.formInline.a=this.$route.query.algorithmId;
                this.getList();
                this.formInline.s=this.$route.query.sceneId;
                this.searchSample();
                console.log(this.formInline)
            }else if(this.$route.query.typeId){
                this.getData();
                this.formInline.t=this.$route.query.typeId;
                this.formInline.a=this.$route.query.algorithmId;
                this.searchSample()
            }else if (isFromEdit) {
                this.getData();
                var filter = this.getCookie("changeFilter");
                if (JSON.stringify(filter) != "{}") {
                    //this.getList();
                    this.formInline = filter;
                    console.log(this.formInline);
                     this.pageIndex = this.formInline.pageIndex;
                     this.pageNum = this.formInline.pageNum;
                };
                this.renderSample()
            }else{
                this.renderSample();
                this.getData()
            }
           this.setCookie('changeFilter','',0);
        },
        beforeRouteEnter(to,from,next) {
            if (from.name == "edit"){
                isFromEdit = true;
            };
            next();
        },

study:https://blog.csdn.net/weixin_34400525/article/details/88744554

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值