Javascript 如何在jade中连接数组?

Javascript 如何在jade中连接数组?,javascript,pug,Javascript,Pug,我试图通过使用for循环将数组c[x].topLevelIndustry中的项连接起来: -var text=""; -var y; script. for (y=0, y< c[x].topLevelIndustry.length, y++){ text+=#{c[x].topLevelIndustry[y]} + ","; } p= text -var text=”“; -变量y; 剧本 对于(y=0,y

我试图通过使用for循环将数组
c[x].topLevelIndustry
中的项连接起来:

 -var text="";
 -var y;
 script.
   for (y=0, y< c[x].topLevelIndustry.length, y++){
     text+=#{c[x].topLevelIndustry[y]} + ",";
   }
 p= text
-var text=”“;
-变量y;
剧本
对于(y=0,y
  • 这怎么能解决呢,我试过很多东西了
  • jade/javascript中变量之间的关系是什么?如果我设置了
    -var somevar
    ,那么如何使它对jade可用

  • 使用script标记可以防止帕格运行代码。相反,它被传递到浏览器以在客户端执行。使用脚本标记而不是脚本标记

    -
      var text = "";
      var y;
      for (y = 0, y < c[x].topLevelIndustry.length, y++){
        text += c[x].topLevelIndustry[y] + ",";
      }
    
    p #{text}
    
    p= c[x].topLevelIndustry.join()