angularjs / JS更新url查询字符串而不刷新/加载

时间:2016-09-06 21:46:19

标签: javascript angularjs

我希望更新网址而不重新加载页面或刷新。我尝试过以下逻辑,但没有运气。每次页面加载。有什么帮助吗?

  var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?k=' + vm.name + '&l=' + vm.sid;
            //var newurl = $location.protocol() + "//" + $location.host() + $location.path() + '?k=' + vm.name + '&l=' + vm.sid
            //window.history.pushState({ path: newurl }, '', newurl);
            //window.history.replaceState(null, null, newurl);
            //window.location.hash = 'k=' + vm.name + '&l=' + vm.sid
            //document.location = newurl;

0 个答案:

没有答案