0

我有一个mixin给我带来了麻烦:

mixin dialog(title, description, choices)
    form.choices.dialog.row
        legend
            h1 #{title}
            p.description #{description}
        fieldset
            for choice in choices
                label
                    input(type= "radio", name = "choice.name", checked = "checked", required = "required")
                    | choice.name
        div.row.form-actions
            button(type="submit", ) Make Choice

为了调用它,我首先将 mixin 文件包含在这个 mixin 中:

import dialog

然后我在创建一个 javascript 变量后使用 mixin:

- var investiageUFODialog = [{headerText: "Would you like to investiage the UFO?", description: "Choose whether or not to investigate the UFO."}, {choices: [{name: "Yes"}, {name: "No"}]}]

mixin dialog(investiageUFODialog.headerText, investiageUFODialog.description, investiageUFODialog.choices)

我究竟做错了什么?

4

1 回答 1

3

investiageUFODialog如果你想这样使用它就不能是一个数组。只需将其更改为:

- var investiageUFODialog = {headerText: "Would you like to investiage the UFO?", description: "Choose whether or not to investigate the UFO.", choices: [{name: "Yes"}, {name: "No"}]}

此外,在您的 mixin 中,您需要编写name = choice.name(不带引号)。

于 2013-04-01T20:19:00.133 回答