【问题标题】:Ember Uncaught TypeError: Cannot read property 'yield' of undefinedEmber Uncaught TypeError:无法读取未定义的属性“yield”
【发布时间】:2016-02-11 09:27:07
【问题描述】:

我们遇到了一个错误 未捕获的类型错误:无法读取未定义的属性“产量” 对于以下hbs代码;

<button {{if isButtonEnabled 'enabled' 'disabled'}}>Test</button>

isButtonEnabled 是我对应的控制器上定义的属性

【问题讨论】:

  • 您能否重现Ember Twiddle 中的错误并为您的问题添加链接?
  • 什么 Ember 版本?

标签: javascript ember.js


【解决方案1】:

你必须改变你的条件并这样做。我刚刚遇到了这个确切的问题,这就是解决方案。

<button disabled={{isButtonDisabled}}>Test<button>

【讨论】:

  • 您不能像在 OP 的代码中那样随意为 HTML 元素添加属性,因为 Ember 没有办法连接到 HTML 中然后更新它。
  • 需要提一下,如果 isButtonDisabled 返回布尔值,则无论哪种方式都将呈现 disabled 属性。只有 NULL 会删除属性
猜你喜欢
  • 2021-04-28
  • 2017-07-20
  • 1970-01-01
  • 2020-03-28
  • 2023-04-11
  • 2016-04-22
  • 2015-06-08
  • 2014-03-17
  • 1970-01-01
相关资源
最近更新 更多