location对象

location表示当前页面的Url信息

location.href; // http://www.example.com:8080/path/index.html?a=1&b=2#TOP

location.protocol; // 'http'

location.host; // 'www.example.com'

location.port; // '8080'

location.pathname; // '/path/index.html'

location.search; // '?a=1&b=2'

location.hash; // 'TOP'

页面切换location.assign('/')
页面刷新location.reload()

location.assign('https://www.baidu.com');
夹具
原文地址:https://www.cnblogs.com/jilaokang/p/8669454.html