翡翠:每个时间的val返回"没有这样的功能:val"

时间:2015-09-01 17:23:08

标签: node.js coffeescript pug

我有以下Jade:

template(name='hello')
    button(class="ui grey basic button", id="clickme")
        i(class="sun icon")
        | Times
    div(class="ui list")
        each val in times
            div.item= val

其中,时间是从JS辅助方法调用的会话变量。

我正在运行Meteor服务器,使用Semantic-UI作为我的设计框架。 当我尝试使用此Jade时,页面检查器控制台(在Chrome中)返回

Uncaught Error: No such function: val

我不知道该修复什么,因为我正在遵循Jade(和Meteor-Jade)文件。

谢谢!

1 个答案:

答案 0 :(得分:0)

each无法与in合作。试试:

<强>玉

div(class="ui list")
  each times
    div.item= val

<强> JS:

if (Meteor.isClient) {
  Session.set('times', [{val: 'value1'}, {val: 'value2'}]);

  Template.hello.helpers({
    times: function () {
      return Session.get('times');
    }
  });
}

或者,如果在Session变量中有数组而不是对象,则可以使用this

<强>玉

div(class="ui list")
  each times
    div.item= this

<强> JS:

if (Meteor.isClient) {
  Session.set('times', ['value1', 'value2']);
  ...
}