KLoction.js 模拟返回window.locatio
KLocation
将输入的字符串使用正则匹配,模拟返回window.location的值
构建状态<script src="./KLocation.js"></script>
or
npm install klocation 实例化:
KLocation("https://github.com?a=1&b=2") /*Objcet{ url:"https://github.com?a=1&b=2", host : "github.com", protocol : "https:", pathname : "/", port : '' hostname : "github.com" }*/ 方法: getParam
获取url参数集合返回一个对象
KLocation(url).getParam() // 返回值 // {a:1,b:2} getHost
获取url对应host
KLocation(url).getHost() // 返回值 // github.com getProtocol
获取url对应协议
KLocation(url).getProtocol() // 返回值 // https: getPort
获取url对应端口
KLocation(url).getPort() // 返回值 // '' getPathname
获取url对应pathname
KLocation(url).getPathname() // 返回值 // "/"
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。