如何在流星选项中传递动态参数

How to pass a dynamic parameter in option in Meteor?

本文关键字:动态 参数 选项 流星      更新时间:2023-09-26

我用翡翠和我的流星。

我想用option关键字传递一个动态参数给一个函数,但我得到以下错误:

玩。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);
}

你可以把它传递给函数,这将是你从数组中得到的值。

In play.jade:
select(id="input"
name="select"
value="a"
style="border-right-color: #c0c0c0 !important;"
type="text")
  each myInput
    <option +testing(this)>+this</option>