【发布时间】:2017-03-30 08:48:24
【问题描述】:
我在 Meteor 上使用 Jade。
我想使用 option 关键字将动态参数传递给函数, 但我收到以下错误:
play.jade:Jade 语法错误:预期标识符、数字、字符串、布尔值、null 或包含在“(”、“)”中的子表达式 {{.}}
见下面我的代码,myInput 函数返回任意值,这些值是列表框的值,测试函数应该打印选择的值。
在play.jade:
select(id="input"
name="select"
value="a"
style="border-right-color: #c0c0c0 !important;"
type="text")
each myInput
<option {{testing #{.}}}>#{.}</option>
在 play.js 中:
myInput = function() {
var myArray = ["ABC", "123", "DEF"];
return myArray;
};
testing: function(param) {
console.log(param);
}
【问题讨论】:
-
你能解释一下吗?
<option {{testing #{.}}}>#{.}</option>我感觉无法解决<option {{ }} >中的其他车把@ -
{{testing}} 是我想要在单击列表框时调用的辅助函数。 #{.} 是每次交互中每个语句传递的值,我将它用作测试函数的参数。如果我只写 或 {{testing "parameter"}}>#{.} 效果很好
标签: javascript meteor pug