diff --git a/demo/components/formDemo.vue b/demo/components/formDemo.vue index 1b6cbd563..34c10b892 100644 --- a/demo/components/formDemo.vue +++ b/demo/components/formDemo.vue @@ -271,6 +271,7 @@ ref="form-validate" :model="validateForm" :rules="validateRules" + :label-width="100" > Test nesting formItem in resetForm + + + + + + { + console.log('blur', value) + callback() + } + var inputNumberValidateChange = (rule, value, callback) => { + console.log('change', value) + callback() + } + var switchValidate = (rule, value, callback) => { + console.log('switch change', value) + callback() + } return { validateForm: { input: "", + inputNumber: undefined, muti: { deep: { select: "" @@ -432,6 +464,14 @@ radio: "" }, validateRules: { + switch: [ + { validator: switchValidate, trigger: 'change' } + ], + inputNumber: [ + { required: true, message: 'input cannot be empty', trigger: 'blur' }, + { validator: inputNumberValidate, trigger: 'blur' }, + { validator: inputNumberValidateChange, trigger: 'change' } + ], input: [ { required: true, message: "input cannot be empty", trigger: "blur" } ], @@ -747,6 +787,18 @@ export default { callback() } } + var inputNumberValidate = (rule, value, callback) => { + console.log('blur', value) + callback() + } + var inputNumberValidateChange = (rule, value, callback) => { + console.log('change', value) + callback() + } + var switchValidate = (rule, value, callback) => { + console.log('switch change', value) + callback() + } return { form: { name: '', @@ -779,6 +831,7 @@ export default { ], validateForm: { input: '', + inputNumber: undefined, muti: { deep: { select: 'Public' @@ -792,6 +845,14 @@ export default { radio: '' }, validateRules: { + switch: [ + { validator: switchValidate, trigger: 'change' } + ], + inputNumber: [ + { type: 'number', required: true, message: 'input cannot be empty', trigger: 'blur' }, + { validator: inputNumberValidate, trigger: 'blur' }, + { validator: inputNumberValidateChange, trigger: 'change' } + ], input: [ { required: true, message: 'input cannot be empty', trigger: 'blur' } ], diff --git a/packages/common/Input/src/main.vue b/packages/common/Input/src/main.vue index 697497af4..d29978ad2 100644 --- a/packages/common/Input/src/main.vue +++ b/packages/common/Input/src/main.vue @@ -75,9 +75,6 @@ export default { }, mixins: [ Emitter ], inject: { - form: { - default: null - }, formItem: { default: null } @@ -129,11 +126,6 @@ export default { isComposing: false } }, - computed: { - validateState () { - return this.formItem ? this.formItem.validateState : '' - } - }, methods: { handleCompositionStart () { this.isComposing = true diff --git a/packages/common/InputNumber/src/main.vue b/packages/common/InputNumber/src/main.vue index c2f800dc8..3246db3f5 100644 --- a/packages/common/InputNumber/src/main.vue +++ b/packages/common/InputNumber/src/main.vue @@ -38,6 +38,7 @@