8000 前端路由 · Issue #21 · shyangs/blog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

前端路由 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and pr 8000 ivacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shyangs opened this issue Jan 31, 2018 · 0 comments
Open

前端路由 #21

shyangs opened this issue Jan 31, 2018 · 0 comments

Comments

@shyangs
Copy link
Owner
shyangs commented Jan 31, 2018
Name 🏠 License 相容 dependencies 說明 / 備註
Crossroads.js 🏠 MIT JS-Signals
Davis.js MIT jQuery
director MIT director.js 簡明中文教學 - 羋老頭@博客園
Finch.js 🏠 MIT
page.js 🏠 MIT IE8+ [path-to-regexp]
PathJS 🏠 MIT IE7+
(itorr) Q.js Apache 2.0 Q.js放棄了 HTML5 State,通過#!格式的 url hash 重現了 url 路由功能
router.js MIT
router5 MIT
Sammy.js 🏠 MIT jQuery
StateMan 🏠 MIT IE6+ 特色:處理深層次的路由,複雜的單頁應用

疑難排解

使用了前端路由後與HTML錨點(anchor)衝突

解法: 放棄HTML錨點使用JS錨點

let scrollToAnchor = (anchorName) => {
    if (anchorName) {
        let anchorElement = document.getElementById(anchorName);  // 要跳轉到的元素
        if(anchorElement){ anchorElement.scrollIntoView(); } // 如果對應元素存在,就捲動到該位置
    }
  }

參考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0