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

View file

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