本文介绍了带有数据切换的 Bootstrap 选项卡导致在 angularjs 中重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚迁移到 AngularJS 1.2.我已经意识到我所有的菜单/导航元素都配置了数据切换,例如:

I've just migrated to AngularJS 1.2. And I've realized that all my menu/navigation elements that were configured with data-toggle, for instance:

<li><a href="#additionalSelection" data-toggle="tab">Additional Selection</a></li>

不再工作了.他们应该使用 id="additionalSelection" 切换元素 - 这就是 Angular &当我使用 Angular 1.0.8 版时,Bootstrap 工作正常.

are not working any more. They should toggle element with id="additionalSelection" - and this is how Angular & Bootstrap worked when I was using version 1.0.8 of Angular.

但是现在,当我单击锚元素时,Angular 会拦截这次单击并尝试转到路由 additionalSelection 并导致页面刷新...

But now, when I click anchor element, Angular intercepts this click and tries to go to route additionalSelection and it causes page refresh...

有办法解决吗?

推荐答案

解决方案就像将 href 属性替换为 data-target 一样简单.这解决了问题:

The solution is as simple as replacing href attribute with data-target. That solves the issue:

<li><a data-target="#additionalSelection" data-toggle="tab">Additional Selection</a></li>

这篇关于带有数据切换的 Bootstrap 选项卡导致在 angularjs 中重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 00:56