Skip to content

Commit a69eada

Browse files
authored
Merge pull request #116 from YouZiXiL/main
refactor(admin): 优化图片上传组件的 multiple 属性处理逻辑- 将 $props['multiple'] 的处理方式从三元运算符改为使用 null 合并运算符 - 这种写法更加简洁,并且在 $props['multiple'] 未设置时默认将其设为 0
2 parents 2c5757a + 0e67598 commit a69eada

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public function uploadImage($options)
369369
[$label, $field, $value, $props, $verify_string, $required_string, $class] = $this->options($options);
370370
$props['acceptMime'] = $props['acceptMime'] ?? 'image/gif,image/jpeg,image/jpg,image/png';
371371
$props['url'] = $props['url'] ?? '/app/admin/upload/image';
372-
$props['multiple'] = $props['multiple'] ? 1 : 0;
372+
$props['multiple'] = $props['multiple'] ?? 0;
373373

374374
$id = $this->createId($field);
375375

@@ -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)