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

Logo

前往低代码交流专区

更多推荐