andy 2 年 前
コミット
b88896a8ea
1 ファイル変更19 行追加13 行削除
  1. 19 13
      backstage/static/js/yo.js

+ 19 - 13
backstage/static/js/yo.js

@@ -1239,19 +1239,25 @@ function GenProductSection(mimg, specimg) {
 
   specimgstr = "";
 
-  for (i = 0; i < specimg.blocks.length; i++) {
-    //alert(block.type);
-    block = specimg.blocks[i];
-    console.log(block);
-    if (block.type == "image") {
-      iurl = block.data.file.url.split("/");
-      if (iurl[iurl.length - 1] != "logo2.png") {
-        specimgstr +=
-          '<h6>尺寸規格</h6><img\n class="w-100 h-100" alt="小寶優居 | ' +
-          $("#ctitle").val() +
-          '"\n  src="img/' +
-          iurl[iurl.length - 1] +
-          '"\n >\n</img>';
+  if(specimg.blocks.length===0){
+    specimgstr = "";
+
+  }else{
+    specimgstr += "<h6>尺寸規格</h6>";
+    for (i = 0; i < specimg.blocks.length; i++) {
+      //alert(block.type);
+      block = specimg.blocks[i];
+      console.log(block);
+      if (block.type == "image") {
+        iurl = block.data.file.url.split("/");
+        if (iurl[iurl.length - 1] != "logo2.png") {
+          specimgstr +=
+            '<img\n class="w-100 h-100" alt="小寶優居 | ' +
+            $("#ctitle").val() +
+            '"\n  src="img/' +
+            iurl[iurl.length - 1] +
+            '"\n >\n</img>';
+        }
       }
     }
   }