我使用的是 Ember Cli 版本:0.2.3
我目前正在探索 Ember,并尝试一个非常简单的应用程序。
我的模板/about.hbs 中有这个
<h1>About</h1>
<p>I'll write something interesting here</p>
<button type="btn btn=primary"{{action 'clickMe'}}>Click me!</button>
在我的 controllers/about_controller.js 中
Blogger.AboutController = Ember.Controller.extend({
actions: {
clickMe: function() {
alert('Something something');
}
}
});
当我单击按钮时出现此错误,我检查了语法但似乎无法发现问题所在。我需要一些新鲜的眼睛。
Uncaught Error: Nothing handled the action 'clickMe'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.
现在,我明白了消息的意思,但我还不知道如何修复它。
最佳答案
Ember 可能找不到您的 Controller 。您可以使用 ember inspector 进行调试.在任何情况下,您都应该在 ember cli 项目中使用 ES6 约定。您可以进一步了解该主题here .
无论如何,尝试使用命令行通过键入创建about
Controller
ember generate controller about
然后手动添加您的操作。
关于javascript - Ember Controller 的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29755799/