Skip to content

Commit f1cf40a

Browse files
committed
feat: 增加预览实例方法
1 parent 83442e2 commit f1cf40a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/BootstrapBlazor/Components/Upload/AvatarUpload.razor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,15 @@ protected override async Task TriggerOnChanged(UploadFile file)
150150
await base.TriggerOnChanged(file);
151151
}
152152

153+
/// <summary>
154+
/// 预览当前头像方法
155+
/// </summary>
156+
/// <returns></returns>
153157
public async Task Preview()
154158
{
155159
if(ShowPreviewList)
156160
{
157-
161+
await InvokeVoidAsync("preview", PreviewerId, 0);
158162
}
159163
}
160164

src/BootstrapBlazor/wwwroot/modules/upload.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ export function init(id) {
8484
})
8585
}
8686

87+
export function preview(previewerId, index) {
88+
const prev = Data.get(previewerId);
89+
if (prev) {
90+
prev.viewer.show(index);
91+
}
92+
}
93+
8794
export async function getPreviewUrl(id, fileName) {
8895
let url = '';
8996
const upload = Data.get(id);

0 commit comments

Comments
 (0)