【问题标题】:Get helper not working for attrs hash获取助手不适用于 attrs 哈希
【发布时间】:2016-01-28 02:35:32
【问题描述】:
{{my-component can-delete=true canDelete=true}}

my-component 模板中,我想从attrs 对象访问can-delete

{{attrs.can-delete}} <!-- does not work, prints blank, should print true -->
{{attrs.canDelete}} <!-- works, prints true-->

我尝试使用 get 助手

{{get attrs 'can-delete'}}

但得到一个错误Uncaught Error: Assertion Failed: The first argument to {{get}} must be a stream

如何从 HTMLBar 中访问非通常格式的对象属性?

【问题讨论】:

  • 你不需要使用“attrs”。去{{can-delete}}

标签: ember.js htmlbars


【解决方案1】:

这是一个 ember-twiddle,即使没有 'get' 助手,它似乎也能正常工作:http://ember-twiddle.com/f101eb114ea0b8ad3e92

【讨论】:

    猜你喜欢
    • 2014-03-04
    • 1970-01-01
    • 2014-11-21
    • 2019-03-20
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多