{"id":17584722,"url":"https://github.com/cssmagic/subview","last_synced_at":"2026-01-21T10:02:20.119Z","repository":{"id":29579232,"uuid":"33118923","full_name":"cssmagic/subview","owner":"cssmagic","description":"View switching with history support.","archived":false,"fork":false,"pushed_at":"2016-05-04T09:55:12.000Z","size":33,"stargazers_count":2,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-07T06:12:44.444Z","etag":null,"topics":["history","mobile-web","single-page-applications","ui","view"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cssmagic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-30T11:21:17.000Z","updated_at":"2016-05-03T05:25:17.000Z","dependencies_parsed_at":"2022-09-15T01:22:58.602Z","dependency_job_id":null,"html_url":"https://github.com/cssmagic/subview","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cssmagic/subview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssmagic%2Fsubview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssmagic%2Fsubview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssmagic%2Fsubview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssmagic%2Fsubview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cssmagic","download_url":"https://codeload.github.com/cssmagic/subview/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssmagic%2Fsubview/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["history","mobile-web","single-page-applications","ui","view"],"created_at":"2024-10-22T02:07:52.799Z","updated_at":"2026-01-21T10:02:20.099Z","avatar_url":"https://github.com/cssmagic.png","language":"JavaScript","readme":"# Subview\n\n\u003e View switching with history support.\n\n## 兼容性\n\n#### 浏览器支持\n\n* 支持以下移动平台的主流浏览器：\n\t* iOS 7+\n\t* Android 4+\n\n* 同样支持以下桌面浏览器：\n\t* Firefox (Latest)\n\t* Chrome (Latest)\n\t* Safari (Latest)\n\n#### 外部依赖\n\n* jQuery（或 Zepto 等兼容类库）-- DOM 操作\n* history.state -- 可选，`history.state` 属性的 polyfill\n* Action -- 可选，点击事件绑定\n\n## 安装\n\n0. 通过 Bower 安装：\n\n\t```sh\n\t$ bower install subview\n\t```\n\n\t如有必要，安装可选依赖：\n\n\t```sh\n\t$ bower install action\n\t$ bower install history.state\n\t```\n\n0. 在页面中加载 Subview 的脚本文件及必要的依赖：\n\n\t```html\n\t\u003c!-- deps --\u003e\n\t\u003cscript src=\"bower_components/jquery/dist/jquery.min.js\"\u003e\u003c/script\u003e\n\t\u003c!-- optional deps --\u003e\n\t\u003cscript src=\"bower_components/history.state/dist/history.state.umd.js\"\u003e\u003c/script\u003e\n\t\u003cscript src=\"bower_components/action/src/action.js\"\u003e\u003c/script\u003e\n\t\u003c!-- this lib --\u003e\n\t\u003cscript src=\"bower_components/subview/src/subview.js\"\u003e\u003c/script\u003e\n\t```\n\n## 使用步骤\n\n#### Polyfill 与 Fallback\n\nSubview 依赖 HTML5 History API，且依赖 `history.state` 属性。为了在那些支持前者但不支持后者的浏览器中正常运行，我们需要对后者进行 polyfill。我们需要 [history.state](https://github.com/cssmagic/history.state) 这个类库来完成 polyfill。\n\n但现实中还存在无法 polyfill 的情况（比如早期的浏览器连基本的 HTML5 History API 都不支持），因此建议你在使用 Subview 之前做好特性检测，并提供 fallback 方案：\n\n```js\nif (historyState.isSupported()) {\n\t// 使用 Subview 提供增强的 UI 效果\n} else {\n\t// Fallback 到基本的 UI 效果\n}\n```\n\n#### 初始化\n\n需要在 DOM ready 时调用 Subview 的初始化方法。（[参见相关文档](https://github.com/cssmagic/subview/issues/2#user-content-js-api-init)）\n\n#### 输出 HTML 接口\n\nSubview 预定义了一些动作，可以借助 [Action](https://github.com/cssmagic/action) 类库自动完成事件绑定，不需要再手工绑定到 DOM 元素。（[参见相关文档](https://github.com/cssmagic/subview/issues/2#user-content-js-api-exportActions)）\n\n## API 文档\n\n所有文档入口在 [Wiki 页面](https://github.com/cssmagic/subview/wiki)，快去看吧！\n\n## 谁在用？\n\n以下开源项目采用 Subview 作为 UI 组件：\n\n* [CMUI](https://github.com/CMUI/CMUI)\n\n因此，本项目运行在以下网站：\n\n* [百姓网 - 手机版](http://m.baixing.com/)\n\n***\n\n## License\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcssmagic%2Fsubview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcssmagic%2Fsubview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcssmagic%2Fsubview/lists"}