-
Notifications
You must be signed in to change notification settings - Fork 0
remote.Function.mountRemote
github-actions[bot] edited this page Jun 8, 2026
·
2 revisions
@zenstone/ts-utils / remote / mountRemote
mountRemote<
K>(scope,options):Promise<MountRemoteResult<Record<string,unknown>>>
Defined in: src/remote/mountRemote.ts:304
挂载远程资源
基于 scope 做 inflight 去重:并发调用同 scope 只执行一次,结果共享。
Options 类型由 type 字段决定,通过 MountHandlerMap 接口扩展。
内置支持 js、mjs、css 三种类型,其他类型需通过
registerMountHandler 注册处理器。
K extends keyof MountHandlerMap
string
去重标识,同时用作 DOM 元素 id(对于 DOM handler)
object & Parameters<MountHandlerMap[K]>[1]
挂载选项,类型由 type 决定
Promise<MountRemoteResult<Record<string, unknown>>>
await mountRemote('jquery', {
type: 'js',
url: 'https://cdn.example.com/jquery.min.js',
});并发去重
await Promise.all([
mountRemote('lib', { type: 'js', url }),
mountRemote('lib', { type: 'js', url }),
]);
// 只加载一次