加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – 与ember.js链接的部分

发布时间:2020-12-17 21:23:59 所属栏目:安全 来源:网络整理
导读:我正在尝试将 bootstrap scrollspy包含在我的ember应用程序中. scrollspy需要href =“#section1”来完成它的工作,这显然让路由器感到困惑.这给了我javascript错误,如未捕获错误:没有路由匹配URL’section1′,并打破我相信的卷轴.始终选择最后一个元素. 还有
我正在尝试将 bootstrap scrollspy包含在我的ember应用程序中.

scrollspy需要href =“#section1”来完成它的工作,这显然让路由器感到困惑.这给了我javascript错误,如未捕获错误:没有路由匹配URL’section1′,并打破我相信的卷轴.始终选择最后一个元素.

还有其他人成功实现这一目标吗?有没有办法告诉路由器不要担心这个视图?

解决方法

“This is not an issue with ScrollSpy,it’s an issue with Ember Router”. –@elise-chant

问题在于它的核心Ember依赖于在网址中黑客攻击哈希(‘#’)并将其用于自己的目的.没有像这样的网址支持 – http://example.com/#/about#faq

@ elise-chant的回复引导我进入core issue,我现在很高兴地报告,从Ember 1.9.0开始,支持多个哈希(‘#’)的url.

Jay Phelps提供了解决方案,最近有这样说:

We can see that it 07002 landed in the stable v1.9.0 release.

There is not yet any code that will actually scroll the page to an
id=”anchor” for you,though. The changes made were to allow that sort
of code to happen. I’ve talked with some of the core members about
such an implementation and still plan to try and add it to core but in
the meantime you can definitely use >=1.9.0 and add your own code to
do so,which should be fairly straight forward for simple cases:

Somethine like this but totally untested:

didTransition: function () {   
 Ember.run.schedule('afterRender',this,function () {
     if (window.location.hash) {
       var el = document.getElementById(window.location.hash.substr(1));
       if (el) {
         el.scrollIntoView();
       }
     }   
   }); 
 }

As I find cycles to work on this I’ll have a working example,but I suggest you plow ahead with your own if you can.

我个人非常希望人们尝试一下,然后在这里报告你如何去做.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读