{"id":24537453,"url":"https://github.com/paraself/vue-async-comp","last_synced_at":"2025-07-15T14:20:19.800Z","repository":{"id":57394515,"uuid":"258468501","full_name":"paraself/vue-async-comp","owner":"paraself","description":"A wrapper class to replace vue async component factory. Mainly help to re-try loading when a chunck fails to load.","archived":false,"fork":false,"pushed_at":"2021-02-27T10:24:40.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T13:21:37.260Z","etag":null,"topics":["async-component","vue","vue-router"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/paraself.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":"2020-04-24T09:35:56.000Z","updated_at":"2021-02-27T10:24:42.000Z","dependencies_parsed_at":"2022-09-08T02:37:32.429Z","dependency_job_id":null,"html_url":"https://github.com/paraself/vue-async-comp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paraself%2Fvue-async-comp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paraself%2Fvue-async-comp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paraself%2Fvue-async-comp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paraself%2Fvue-async-comp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paraself","download_url":"https://codeload.github.com/paraself/vue-async-comp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248989120,"owners_count":21194532,"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":["async-component","vue","vue-router"],"created_at":"2025-01-22T14:12:45.111Z","updated_at":"2025-04-15T01:34:29.072Z","avatar_url":"https://github.com/paraself.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-async-comp\n\nA wrapper class to replace vue async component factory. Mainly help to re-try loading when a chunck fails to load.\n\nThe original vue [async component factory](https://vuejs.org/v2/guide/components-dynamic-async.html#Handling-Loading-State) does not offer a way to reload when chunck fail to load. The wrapper class can help reloading chunks.\n\nVue 异步组件加载器，主要用于当异步组件懒加载失败的时候，能够重新加载该chunk。Vue[默认的异步组件工厂函数](https://vuejs.org/v2/guide/components-dynamic-async.html#Handling-Loading-State)没有提供重试的方法，通过该插件可以方便的在chunk加载失败的时候，重新加载对应的chunk。\n\n## Install\n```\nnpm i -S vue-async-comp\n```\n\n## Usage\nRouting\n``` ts\nimport RouteLoading from './RouteLoading.vue'\nimport RouteError from './RouteError.vue'\nimport { AsyncComp } from 'vue-async-comp'\n\nconst asyncComp = new AsyncComp({\n  error: CompError,\n  loading: CompLoading\n})\n\nconst routes: RouteConfig[] = [\n  {\n    path: '/',\n    component: asyncComp.load(import('../MyHome.vue'))\n  }\n]\n\nconst router = new VueRouter({\n  routes,\n  mode: 'history'\n})\n```\n\nor along with `vue-class-component`\n``` ts\n@Component({\n  components: {\n    MyComp: asyncComp.load(import('../MyComp.vue'))\n  }\n})\nexport default class Test extends Vue {\n}\n```\n\n## Chunk reloading\nIn `Error.vue`, emit `reload` event.\n``` vue\n\u003ctemplate\u003e\n\u003cdiv class=\"btn\" @click=\"$emit('reload')\"\u003e\n  click to reload\n\u003c/div\u003e\n\u003c/template\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparaself%2Fvue-async-comp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparaself%2Fvue-async-comp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparaself%2Fvue-async-comp/lists"}