增加路由异步加载

master 1.3.7
yutent 2024-05-09 16:15:52 +08:00
parent b7567a15fc
commit a1c1740166
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "wkitd", "name": "wkitd",
"version": "1.3.6", "version": "1.3.7",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"files": [ "files": [

View File

@ -152,8 +152,16 @@ class Router {
#exec(route) { #exec(route) {
let $view = window.wkitd.get(__ROUTER_VIEW__) let $view = window.wkitd.get(__ROUTER_VIEW__)
let table = this.#tables.get(route.path)
$view.current = route.name $view.current = route.name
this.#route = route this.#route = route
if (typeof table.component === 'function') {
if (!customElements.get(route.name)) {
table.component()
delete table.component //避免多次请求
}
}
this.#broadcast() this.#broadcast()
} }