Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript js-知道列表中是否只有一项_Javascript_Mustache - Fatal编程技术网

Javascript js-知道列表中是否只有一项

Javascript js-知道列表中是否只有一项,javascript,mustache,Javascript,Mustache,目前,当我看到作者的展示时,我正在循环使用胡子 {{#authors}}{{.}}, {{/authors}} //loop through each author names in authors array 问题是结尾的逗号。我更喜欢数据(来自服务器的JSON)保持不变。“小胡子”中有没有办法知道您是否在最后一次迭代中(不加逗号),或者知道您是否在第一次迭代中(不加逗号)未测试 概述:为除名字外的所有名称添加前缀“,” 模板: {{#beatles}} {{name}} {{/beat

目前,当我看到作者的展示时,我正在循环使用胡子

{{#authors}}{{.}}, {{/authors}} //loop through each author names in authors array
问题是结尾的逗号。我更喜欢数据(来自服务器的JSON)保持不变。“小胡子”中有没有办法知道您是否在最后一次迭代中(不加逗号),或者知道您是否在第一次迭代中(不加逗号)

未测试

概述:为除名字外的所有名称添加前缀“,”

模板:

{{#beatles}}
  {{name}}
{{/beatles}}
初始化:

window.app.first_flag = true; // initialize
// assumes that the app has created the window.app object/hash to 
// hold the app's data
视图:

没有测试

概述:为除名字外的所有名称添加前缀“,”

模板:

{{#beatles}}
  {{name}}
{{/beatles}}
初始化:

window.app.first_flag = true; // initialize
// assumes that the app has created the window.app object/hash to 
// hold the app's data
视图:


在我的数组中,我没有对象,只有字符串。我无法
执行此操作。firstname
如何引用它们?在数组中,我没有对象,只有字符串。我不能
这样做。firstname
我如何引用它们?