我正在使用 ember-validations 和 EmberFire 创建一个注册表单。我的服务器启动正常,但我的控制台显示此错误:
Uncaught Error: Could not find module `app/mixins/validations/signup` imported from `processapp/controllers/signup`
这是我的注册验证 mixin 的代码:
import Ember from 'ember';
import EmberValidations from 'ember-validations';
export default Ember.Mixin.create(EmberValidations, {
validations: {
"model.firstName": {
presence: true
},
"model.lastName": {
presence: true
},
"model.email": {
format: { with: /^.+@.+\..+$/, message: 'Please enter a valid email address.' }
},
"model.password": {
length: {minimum: 6, maximum: 30},
presence: true,
confirmation: true
}
},
});
这是我的注册控制器的代码:
import Ember from 'ember';
import SignupValidations from 'app/mixins/validations/signup';
export default Ember.Controller.extend(SignupValidations, {
actions: {
createUser(){
//...
this.validate().then(()=>{
var newUser = this.store.createRecord('user', {
firstName: this.get('firstName'),
lastName: this.get('lastName'),
email: this.get('email'),
password: this.get('password')
});
newUser.save().then(()=>{
this.transitionToRoute('user', newUser);
});
}).catch(()=>{
console.log(this.get("errors"));
});
}
}
});
文件结构似乎与我的控制器中 import SignupValidations 行中包含的结构相匹配,所以我对为什么会收到此错误感到有些困惑。有任何想法吗?