获取url后边的参数和window.location的属性

     获取url后边的参数:

const params = new URLSearchParams(window.location.search); //获取
                this.channeltype = params.get('channeltype');
                this.mediacode = params.get('mediacode');
                this.form.characteristic = params.get('from');
                this.adid = params.get('adid');
                this.flag = params.get('flag');
                console.log(this.form.characteristic)
    },

 window.location 对象所包含的属性:

属性 描述
hash 从#开始的URL(锚)
host 主机名和当前的URL的端口号
hostname 当前URL的主机名
href 完整的URL
pathname 当前URl的路径部分
port 当前URL的端口号
protocol 当前URL的协议
search 从问号(?)开始的URL(查询部分)

 

posted @ 2022-02-21 17:51  小北养只猫  阅读(315)  评论(0)    收藏  举报