Ember-CLI 앱을 개발 중입니다. 나는 설치했다
양식이 제대로 생성됩니다. 그러나 유효성 검사는 트리거되지 않습니다.
{{#em-form model=controller class="col-md-5"}}
{{em-input property="title" label="Title" placeholder="Title"}}
{{em-text property="description" label="Description" placeholder="Description"}}
{{/em-form}}
유효성 검사가있는 컨트롤러 코드는 다음과 같습니다.
import Ember from "ember";
export default Ember.Controller.extend({
actions: {
submit: function() {
}
},
validations: {
title: {
presence: true,
length: { minimum: 5, maximum: 10 }
}
}
});
어떤 생각?
문서에 따르면 "EmberValidations.Mixin을 유효성 검사를 추가하려는 Ember.Object에 혼합해야합니다." 다음과 같이 작동하는 것 같습니다.
import Ember from "ember";
import EmberValidations from 'ember-validations';
export default Ember.Controller.extend(EmberValidations.Mixin, {
actions: {
submit: function() {
}
},
validations: {
title: {
presence: true,
length: { minimum: 5, maximum: 10 }
}
}
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다