support Form

support Form
This commit is contained in:
梁灏 2017-03-08 15:31:59 +08:00
parent 531cd1654b
commit 257f80f1c2
7 changed files with 52 additions and 43 deletions

View file

@ -3,7 +3,9 @@
<label :class="[prefixCls + '-label']" :style="labelStyles" v-if="label"><slot name="label">{{ label }}</slot></label>
<div :class="[prefixCls + '-content']" :style="contentStyles">
<slot></slot>
<div transition="fade" :class="[prefixCls + '-error-tip']" v-if="validateState === 'error' && showMessage && form.showMessage">{{ validateMessage }}</div>
<transition name="fade">
<div :class="[prefixCls + '-error-tip']" v-if="validateState === 'error' && showMessage && form.showMessage">{{ validateMessage }}</div>
</transition>
</div>
</div>
</template>
@ -11,6 +13,7 @@
// https://github.com/ElemeFE/element/blob/dev/packages/form/src/form-item.vue
import AsyncValidator from 'async-validator';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-form-item';
@ -38,6 +41,8 @@
}
export default {
name: 'FormItem',
mixins: [ Emitter ],
props: {
label: {
type: String,
@ -206,9 +211,9 @@
this.validate('change');
}
},
ready () {
mounted () {
if (this.prop) {
this.$dispatch('on-form-item-add', this);
this.dispatch('iForm', 'on-form-item-add', this);
Object.defineProperty(this, 'initialValue', {
value: this.fieldValue
@ -229,7 +234,7 @@
}
},
beforeDestroy () {
this.$dispatch('on-form-item-remove', this);
this.dispatch('iForm', 'on-form-item-remove', this);
}
};
</script>