{"id":24998180,"url":"https://github.com/geminate/megalo-router-patch","last_synced_at":"2025-04-12T06:24:34.342Z","repository":{"id":57294239,"uuid":"157675117","full_name":"geminate/megalo-router-patch","owner":"geminate","description":"在 megalo 中使用 vue-router 的路由写法","archived":false,"fork":false,"pushed_at":"2018-12-10T03:46:24.000Z","size":8,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T01:51:07.670Z","etag":null,"topics":["megalo","router","vue","vue-router"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geminate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-15T08:09:38.000Z","updated_at":"2024-02-19T06:45:13.000Z","dependencies_parsed_at":"2022-08-29T07:51:05.885Z","dependency_job_id":null,"html_url":"https://github.com/geminate/megalo-router-patch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geminate%2Fmegalo-router-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geminate%2Fmegalo-router-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geminate%2Fmegalo-router-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geminate%2Fmegalo-router-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geminate","download_url":"https://codeload.github.com/geminate/megalo-router-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248526341,"owners_count":21118866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["megalo","router","vue","vue-router"],"created_at":"2025-02-04T17:39:44.818Z","updated_at":"2025-04-12T06:24:34.316Z","avatar_url":"https://github.com/geminate.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# megalo-router-patch\n\u003e 在 [megalo](https://github.com/kaola-fed/megalo) 中使用 vue-router 的路由写法, 可自动转换为对应小程序的路由写法。\n\n## 安装\n``` bash\nnpm i megalo-router-patch\n```\n\n## 使用\n``` bash\n// main.js\nimport Vue from 'vue'\nimport MegaloRouterPatch from 'megalo-router-patch'\n\nVue.use(MegaloRouterPatch)\n```\n\n## Api\n\n### this.$router\n\n#### 属性\n- this.$router.app\n\n当前页面实例\n\n- this.$router.currentRoute\n\n当前页面的路由信息对象，和 this.$route 相同\n\n#### 方法\n- this.$router.push(location, onComplete, onAbort, onSuccess)\n```js\n// 跳转至某页面(字符串形式)   ---\u003e   navigateTo()\nthis.$router.push('/pages/home/index')\n\n// 跳转至某页面(对象形式)   ---\u003e   navigateTo()\nthis.$router.push({ path: '/pages/home/index' })\n\n// 跳转至某页面(带参数)   ---\u003e   navigateTo()\nthis.$router.push({ path: '/pages/home/index', query: { id: 1 } })\n\n// Tab 切换   ---\u003e   switchTab()\nthis.$router.push({ path: '/pages/home/index', isTab: true })\n\n// 重启至某页面   ---\u003e   reLaunch()\nthis.$router.push({ path: '/pages/home/index', reLaunch: true })\n```\n- this.$router.replace(location, onComplete, onFail, onSuccess)\n```\n// 关闭当前页面，跳转至某页面   ---\u003e   redirectTo()\nthis.$router.replace('/pages/home/index')\n```\n- this.$router.go(delta)\n```\n// 返回多级页面   ---\u003e   navigateBack()\nthis.$router.go(4)\n```\n- this.$router.back()\n```\n// 返回上一页面   ---\u003e   navigateBack()\nthis.$router.back()\n```\n\n### this.$route\n\n#### 属性\n- this.$router.path\n\n当前页面的路径字符串\n```\n\"/pages/home/index\"\n```\n\n- this.$router.query\n\n当前页面的参数对象\n```\n{\n    name: geminate,\n    age: 23\n}\n```\n\n- this.$router.fullPath\n```\n\"/pages/home/index?name=geminate\u0026age=23\"\n```\n\n当前页面的完整路径，包含查询参数等\n\n- this.$router.name\n\n自动生成的页面名称\n```\n\"pagesHomeIndex\"\n```\n\n## TODO\n- [ ] 导航守卫\n\n\n***\n\u003e 参考自 [mpvue-router-patch](https://github.com/F-loat/mpvue-router-patch)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeminate%2Fmegalo-router-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeminate%2Fmegalo-router-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeminate%2Fmegalo-router-patch/lists"}