change Form provide name

This commit is contained in:
梁灏 2019-09-16 18:46:14 +08:00
parent f5c3f91fc6
commit e522134d24
2 changed files with 11 additions and 11 deletions

View file

@ -1,10 +1,10 @@
<template>
<div :class="classes">
<label :class="[prefixCls + '-label']" :for="labelFor" :style="labelStyles" v-if="label || $slots.label"><slot name="label">{{ label }}{{ form.colon }}</slot></label>
<label :class="[prefixCls + '-label']" :for="labelFor" :style="labelStyles" v-if="label || $slots.label"><slot name="label">{{ label }}{{ FormInstance.colon }}</slot></label>
<div :class="[prefixCls + '-content']" :style="contentStyles">
<slot></slot>
<transition name="fade">
<div :class="[prefixCls + '-error-tip']" v-if="validateState === 'error' && showMessage && form.showMessage">{{ validateMessage }}</div>
<div :class="[prefixCls + '-error-tip']" v-if="validateState === 'error' && showMessage && FormInstance.showMessage">{{ validateMessage }}</div>
</transition>
</div>
</div>
@ -98,7 +98,7 @@
this.setRules();
}
},
inject: ['form'],
inject: ['FormInstance'],
computed: {
classes () {
return [
@ -118,7 +118,7 @@
// return parent;
// },
fieldValue () {
const model = this.form.model;
const model = this.FormInstance.model;
if (!model || !this.prop) { return; }
let path = this.prop;
@ -130,7 +130,7 @@
},
labelStyles () {
let style = {};
const labelWidth = this.labelWidth === 0 || this.labelWidth ? this.labelWidth : this.form.labelWidth;
const labelWidth = this.labelWidth === 0 || this.labelWidth ? this.labelWidth : this.FormInstance.labelWidth;
if (labelWidth || labelWidth === 0) {
style.width = `${labelWidth}px`;
@ -139,7 +139,7 @@
},
contentStyles () {
let style = {};
const labelWidth = this.labelWidth === 0 || this.labelWidth ? this.labelWidth : this.form.labelWidth;
const labelWidth = this.labelWidth === 0 || this.labelWidth ? this.labelWidth : this.FormInstance.labelWidth;
if (labelWidth || labelWidth === 0) {
style.marginLeft = `${labelWidth}px`;
@ -165,7 +165,7 @@
this.$on('on-form-change', this.onFieldChange);
},
getRules () {
let formRules = this.form.rules;
let formRules = this.FormInstance.rules;
const selfRules = this.rules;
formRules = formRules ? formRules[this.prop] : [];
@ -204,7 +204,7 @@
callback(this.validateMessage);
this.form && this.form.$emit('on-validate', this.prop, !errors, this.validateMessage || null)
this.FormInstance && this.FormInstance.$emit('on-validate', this.prop, !errors, this.validateMessage || null)
});
this.validateDisabled = false;
},
@ -212,7 +212,7 @@
this.validateState = '';
this.validateMessage = '';
let model = this.form.model;
let model = this.FormInstance.model;
let value = this.fieldValue;
let path = this.prop;
if (path.indexOf(':') !== -1) {

View file

@ -49,8 +49,8 @@
default: false
}
},
provide() {
return { form : this };
provide () {
return { FormInstance : this };
},
data () {
return {