Skip to content

Commit 35440b1

Browse files
committed
fix(admin): 修复图片列表字段为空时的报错问题
- 在 Layui.php 文件中,对图片列表模板进行了修改 -增加了对字段存在性的判断,避免在字段不存在时进行分割操作 - 优化了代码结构,提高了代码的健壮性和可读性
1 parent 277e651 commit 35440b1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/plugin/admin/app/common/Layui.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,17 @@ public static function buildTable($table, int $indent = 0)
10701070
EOF;
10711071
} else {
10721072
$templet = <<<EOF
1073+
10731074
templet: function (d) {
1074-
const images = d['$field'].split(',');
1075-
let html = '';
1075+
let html = '';
1076+
if(d['$field']){
1077+
const images = d['$field'].split(',');
1078+
10761079
for (let img of images) {
10771080
html += '<img src="' + encodeURI(img.trim()) + '" style="max-width:32px;max-height:32px;" alt="" />';
10781081
}
1082+
}
1083+
10791084
return html;
10801085
}
10811086
EOF;

0 commit comments

Comments
 (0)