feat(router): 增强路由组件加载逻辑
- 添加组件加载成功日志记录 - 在加载脚本前输出调试信息 - 更新模块导入后的日志格式 - 优化组件实例获取流程 - 改进依赖脚本加载顺序 - 增加对模块类型判断的日志输出
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 267 B |
@@ -10,16 +10,16 @@ export class ScriptManager {
|
||||
console.log('loadScript', name);
|
||||
if (this._loadedClasses.has(name)) {
|
||||
console.log(`Component ${name} loaded from cache`);
|
||||
return this._loadedClasses.get(name);
|
||||
}
|
||||
|
||||
console.log('deps', deps);
|
||||
for (const dep of deps) {
|
||||
await this._appendScript({path: dep, isModule: false});
|
||||
}
|
||||
|
||||
let componentReference = null;
|
||||
|
||||
console.log(isModule);
|
||||
console.log(`isModule:${isModule}`);
|
||||
if (isModule) {
|
||||
const module = await import(path);
|
||||
this.currentModule = module;
|
||||
|
||||
@@ -84,13 +84,20 @@ class Router {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('加载组件', route.name);
|
||||
console.log(route.script);
|
||||
if (route.script) {
|
||||
await this.scriptManager.loadScript({
|
||||
const tmp = await this.scriptManager.loadScript({
|
||||
path: route.script,
|
||||
name: route.name,
|
||||
isModule: route.isModule,
|
||||
deps: route.deps,
|
||||
});
|
||||
|
||||
console.log(tmp);
|
||||
if (tmp) {
|
||||
console.log('加载组件成功', route.name);
|
||||
}
|
||||
}
|
||||
|
||||
const newInstance = await this.scriptManager.getComponentInstance(route.name);
|
||||
|
||||
Reference in New Issue
Block a user