HTML
<div class="layui-upload-list">
<img class="layui-upload-img" src="url" style="width: 92px; height: 92px;" id="image" onclick="onImgThumbnail("url");">
</div>
点击图片展示效果
js
function onImgThumbnail(url){
layui.use('layer', function(){
var layer = layui.layer;
var filePath = url.toLowerCase().split("."); //截取逗号
var fileType = filePath[filePath.length - 1]; //文件类型
if(fileType == "pdf" || fileType == "doc" || fileType == "xlsx" || fileType == "zip" || fileType == "ppt"){
parent.layer.msg("文件格式不正确!");
return false;
}
var imgHtml = "<img src='" + url + "' />";
parent.layer.open({
type: 1,
title: false, //不显示标题
area:['600px','500px'],
content: imgHtml
});
});
}