{"id":19411264,"url":"https://github.com/monster1935/vue-admin","last_synced_at":"2025-04-24T10:33:10.827Z","repository":{"id":209146501,"uuid":"106627431","full_name":"monster1935/vue-admin","owner":"monster1935","description":"基于vue+element-ui的后台管理系统动态tabs实践","archived":false,"fork":false,"pushed_at":"2017-12-20T14:16:28.000Z","size":1111,"stargazers_count":212,"open_issues_count":4,"forks_count":64,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-11-25T12:28:03.017Z","etag":null,"topics":["admin","element-ui","tabs","vue"],"latest_commit_sha":null,"homepage":null,"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/monster1935.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,"governance":null}},"created_at":"2017-10-12T01:07:29.000Z","updated_at":"2023-11-25T12:28:08.183Z","dependencies_parsed_at":"2023-11-25T12:28:06.159Z","dependency_job_id":"e43f4b52-6365-4849-b298-c7afa87cbeda","html_url":"https://github.com/monster1935/vue-admin","commit_stats":null,"previous_names":["monster1935/vue-admin"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monster1935%2Fvue-admin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monster1935%2Fvue-admin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monster1935%2Fvue-admin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monster1935%2Fvue-admin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monster1935","download_url":"https://codeload.github.com/monster1935/vue-admin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223949747,"owners_count":17230348,"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":["admin","element-ui","tabs","vue"],"created_at":"2024-11-10T12:19:53.268Z","updated_at":"2024-11-10T12:19:53.765Z","avatar_url":"https://github.com/monster1935.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# vue-admin\n\n基于vue、element-ui的后台管理系统demo，主要是做了动态操作tabs的实践。\n效果图：\n\n![](https://raw.githubusercontent.com/monster1935/vue-admin/master/static/vue-admin.png)\n\n在线demo：[online display](https://monster1935.github.io/vue-admin/#/)\n\n动态tabs操作的思路：\n\n1. 设置一源数组options，该数组用于动态的渲染tabs\n2. 点击左侧菜单导航栏时动态的push进options一条数据\n3. 删除tabs时，动态的删除options的一条数据\n\n其中的难点（稍有点麻烦的地方）就是和路由之间的绑定，涉及到路由绑定的有以下几个地方：\n\n1. 点击左侧菜单栏时路由需要进行跳转\n2. 切换、删除右侧tab时需要进行路由的跳转\n3. 浏览器地址栏手动输入路由时进行的跳转\n\n综上：\n\n1. 应用进入时，即首次mounted时，应判断当前路由，根据当前路由加入tabs。目的在于刷新当前浏览器时，保证当前url对应的路由会被添加进tab。\n2. 左侧菜单栏点击时，只进行路由的跳转，具体的tabs添加动作放在对$route的监听逻辑中\n3. 在对$route的监听逻辑中，判断当前路由是否被添加过tabs，如果添加过，设置当前路由对应的tabs为激活的tab。如果未被添加过，则添加。\n4. tabs切换时，动态切换路由\n5. tabs删除时，options源数组中删除该条tabs记录，如果删除的这个tab为当前激活的tab，重新设置新的激活的tab，具体的设置激活tab的策略可以不同，该应用中采用了设置最后一个options中的记录为激活的tab。\n\n小技巧：\n\n在设置路由的配置项时，将路由的name项设置为了tabs对应的label，用于路由配置项和对应的tabs匹配。\n\n# how to use\n```bash\n\nnpm install\n\nnpm run dev\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonster1935%2Fvue-admin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonster1935%2Fvue-admin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonster1935%2Fvue-admin/lists"}