Skip to content

Commit b08d53a

Browse files
committed
refactor: 增加 LoadModuleByName 扩展方法
1 parent 63af32a commit b08d53a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/BootstrapBlazor/Extensions/JSModuleExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ public static class JSModuleExtensions
1616
/// <param name="jsRuntime"></param>
1717
/// <param name="version"></param>
1818
/// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> 模块加载器</returns>
19-
public static Task<JSModule> LoadUtility(this IJSRuntime jsRuntime, string? version = null) => LoadModule(jsRuntime, "./_content/BootstrapBlazor/modules/utility.js", version);
19+
public static Task<JSModule> LoadUtility(this IJSRuntime jsRuntime, string? version = null) => LoadModuleByName(jsRuntime, "utility", version);
20+
21+
internal static Task<JSModule> LoadModuleByName(this IJSRuntime jsRuntime, string moduleName, string? version = null)
22+
{
23+
var fileName = $"./_content/BootstrapBlazor/modules/{moduleName}.js";
24+
return LoadModule(jsRuntime, fileName, version);
25+
}
2026

2127
/// <summary>
2228
/// IJSRuntime 扩展方法 动态加载脚本 脚本目录为 modules

0 commit comments

Comments
 (0)