gpt4 book ai didi

javascript - emberjs 表单提交操作错误

转载 作者:行者123 更新时间:2023-12-03 10:19:19 26 4
gpt4 key购买 nike

我正在尝试在注册表单上创建提交操作。这是我的寄存器 handle :

  <form class="form-signin" {{action "register" on="submit"}}>
{{input class="form-control" value=username type="text" placeholder="Username"}}
{{input class="form-control" value=password type="password" placeholder="Password" }}
<button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
</form>

这是路由器:

import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
location: config.locationType
});

Router.map(function() {
this.resource('register', {path: '/register'});
});

export default Router;

这是我的注册 Controller :

import Ember from 'ember';

export default Ember.Controller.extend({
register: function(){
return 'hello';
}
});

当我提交表单时,出现此错误:

Uncaught Error: Nothing handled the action 'register'. 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.

我做错了什么?

最佳答案

我缺少 Controller 中的操作属性。它应该看起来像这样:

从“ember”导入 Ember;

export default Ember.Controller.extend({
actions: {
register: function(){
alert('hey');
}
}
});

关于javascript - emberjs 表单提交操作错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29719958/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com