假设我的网页是 http://localhost/myApp/route/index.html
如果我单击:
<li><a href="#secondpage">go to second page</a></li>
它将路线更改为,http://localhost/myApp/route/index.html#/secondpage
而无需重新加载。
现在,我尝试执行相同的操作,但仅使用onclick和javascript而不是锚标记。因为我需要先做一些事情,然后才能将角度路由器更改为另一个模板。
<li><a onClick="myFunction()">Payroll Run History</a></li>
myFunction(){
[... do stuff ...]
//change to http://localhost/myApp/route/index.html#/secondpage without reloading page
}
设置锚属性:
location.hash = "#/secondpage";
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句