用法:
<link href="/path/to/viewer.css" rel="stylesheet"> <script src="/path/to/viewer.js"></script> new Viewer(element[, options]) 【element: HTMLElement类型,可以是img元素或包含img的元素】详细见: https://github.com/fengyuanchen/viewerjs/blob/main/README.md
官网展示效果:https://fengyuanchen.github.io/viewerjs/
最简单的用法:
function UploaderShowGridFileEx(currentIndex, img) {
$("#UploaderHiddenImg").remove();
if (img.length > 0) {
$("body").append('<div id="UploaderHiddenImg" style="display:none;"></div>');
$.each(img, function (index, value) {
$("#UploaderHiddenImg").append('<img src="' + value.Url + '" alt="' + value.Alt + '"/>');
});
var viewer = new Viewer(document.getElementById('UploaderHiddenImg'), {
initialViewIndex: currentIndex,
hidden: function () {
viewer.destroy();
$("#UploaderHiddenImg").remove();
}
});
viewer.show();
}
}