首页 > 解决方案 > Ember:无法识别 camelCase 助手引用

问题描述

我将 Ember CLI 从 2.4.6 升级到 2.8.0。在此之后,模板中由 camelCase 名称引用的助手会抛出错误Assertion Failed: A helper named "helperName" could not be found。如果我将引用更改为helper-namefrom helperName,则一切正常。

标签: ember.jsember-cli

解决方案


在最近的 ember 版本中,如果您的助手中有一个破折号(helpers/helper-name.js),那么在您的模板中使用花括号将其调用为{{helper-name}}. 在您的情况下,您的助手是,dasherized但您正在使用camelCase.

余烬中2.4参考

Unlike components, helpers do not require a dash (-) character in their name.

余烬中2.8参考

Unlike components, which require a dash in the name to follow the Custom Element spec, helper names can be single or multi-word. If your helper's name is multi-word, it should be dasherized in your template.


推荐阅读