我试图使用该组件bs-button的灰烬引导派遣一个简单的动作,将写日志的东西。为此,我ember-cli根据项目 Github 页面使用并安装了 ember-bootstrap创建了一个新应用程序。
然后,我使用 ember-cli ( ember g route myroute)创建了一个路由并编写了以下代码:
应用程序/路由/myroute.js
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
actionTest(value){
console.log('on actionTest:', value);
}
}
});
Run Code Online (Sandbox Code Playgroud)
应用程序/模板/myroute.hbs
{{#bs-button onClick=(action "actionTest")}}Run test action{{/bs-button}}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试访问时,控制台中出现以下错误(没有呈现任何内容):
message: "Assertion Failed: An action named 'actionTest' was not found in (generated myroute controller)"
Run Code Online (Sandbox Code Playgroud)
其次是:
Uncaught TypeError: Cannot read property 'getAttribute' of undefined
Run Code Online (Sandbox Code Playgroud)
也许是一个完全愚蠢的错误,但我在文档和示例中都没有发现任何内容。
环境:
余烬cli:
$ ember -v
ember-cli: 2.10.1
node: 6.9.2
os: darwin x64 …Run Code Online (Sandbox Code Playgroud)