From 746bd44e1610cce32236ea064b7111498f4683e3 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 28 Jul 2022 11:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20layer.photos=20=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E6=8F=90=E7=A4=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/layer.js | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/modules/layer.js b/src/modules/layer.js index 8e59e25e..4f0cba9b 100644 --- a/src/modules/layer.js +++ b/src/modules/layer.js @@ -1280,6 +1280,8 @@ layer.photos = function(options, loop, key){ loadImage(data[start].src, function(img){ layer.close(dict.loadi); + let alt = data[start].alt||''; + //切换图片时不出现动画 if(key) options.anim = -1; @@ -1317,15 +1319,36 @@ layer.photos = function(options, loop, key){ isOutAnim: false, skin: 'layui-layer-photos' + skin('photos'), content: '
' - +''+ (data[start].alt||'') +'' + +''+ alt +'' +function(){ + let tip = '
'; + if(data.length > 1){ - return '
' - +'' - +'
'+ (data[start].alt || '') +''+ dict.imgIndex +' / '+ data.length +'
' - +'
' + tip += ''; + + if(alt===''){ + tip += '
'+ dict.imgIndex +' / '+ data.length +'
'; + } + else{ + tip += '
'+ alt +''+ dict.imgIndex +' / '+ data.length +'
'; + } + + tip += '
'; } - return ''; + else if(data.length === 1){ + if(alt===''){ + tip = ''; + } + else{ + tip += '
'+ alt +'
'; + tip += '
'; + } + } + else{ + tip = ''; + } + + return tip; }() +'', success: function(layero, index){