大佬教程收集整理的这篇文章主要介绍了angular-ui-router – 如何使用ui路由器在html中使用锚点,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
.state('home',{ url: '/home',templateUrl: 'view/home/home.html',controller: 'homeCtrl' }) .state('guide',{ url: '/guide',templateUrl: 'view/guide/guide.html',controller: 'guideCtrl' })
我可以在浏览器中访问网址,http://localhost:8000/dist/#/home
但是,我不能在我的HTML中使用锚点
如果home.html中有这样的锚点
<a href="#aaa">scroll to aaa</a> .... <h1 id="aaa">AAA</h1>
当我点击“滚动到aaa”时,网址将为http://localhost:8000/dist/#/aaa
并返回一个空白页.home.html中的锚点不起作用.
我该如何解决这个问题?
鉴于您的路由设置:
.state('home',{ url: '/home',controller: 'homeCtrl' }) .state('guide',{ url: '/guide',controller: 'guideCtrl' })
在任何视图上创建链接:
<a href="" ui-sref="home({'#': 'aaa'})">Scroll to AAA</a>
在页面视图/ home / home.html
.... .... <h1 id="aaa">AAA</h1>
以上是大佬教程为你收集整理的angular-ui-router – 如何使用ui路由器在html中使用锚点全部内容,希望文章能够帮你解决angular-ui-router – 如何使用ui路由器在html中使用锚点所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。