模块化开发中带着参数跳转页面进行回显的描述!

//统一页面跳转方法
    util.goPage = function (type,url,params) {
        switch (type){
            //配置跳转
            case 0:
                var jump = '';
                if(params){
                    jump = config.routes(url) + '?' + params;
                }else{
                    jump = config.routes(url);
                }
                location.href = jump;
                break;
            //页面跳转
            case 1:
                location.href = url;
                break;
            //返回上一个页面
            case 2:
                window.history.go(-1);
                break;
            //返回并刷新上一个页面
            case 3:
                location.href = document.referrer;
        }
    };

一,场景是一个搜索框,带着参数跳转到另一个页面,并且回显参数

mod.requestlistdata = function () {
            var params = $("#search-box-input").val();
            var url = "tianyancha-list.html?word="+decodeURI(encodeURIComponent(params));
            util.goPage(1,url);
        }

其中跳转到另一个页面之后,获取参数

var subAcct = util.getAllQueryString();
var word=decodeURIComponent(subAcct.word); //防止出现乱码

二,场景是,模板ejs是同一个,但是跳转页面时需要拿到ajax的一个字段的不同,ejs的字段也不同


我们在span标签中加一个“data-year”属性表示我们想要的字段



猜你喜欢

转载自blog.csdn.net/weixin_40756395/article/details/79508898