From 4e31085656024415d21d3e4955ca3f590cde48fe Mon Sep 17 00:00:00 2001 From: BillyWang <181347204@qq.com> Date: Wed, 28 Mar 2018 22:42:16 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E9=87=87=E7=94=A8inject=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3=E9=97=AE=E9=A2=98=EF=BC=9A=E5=BD=93?= =?UTF-8?q?FormItem=E7=BB=84=E4=BB=B6=E5=9C=A8slot=E9=87=8C=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=8E=B7=E5=8F=96?= =?UTF-8?q?form=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/form/form-item.vue | 15 ++++++++------- src/components/form/form.vue | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/form/form-item.vue b/src/components/form/form-item.vue index 17fb9885..1fc20196 100644 --- a/src/components/form/form-item.vue +++ b/src/components/form/form-item.vue @@ -92,6 +92,7 @@ this.validateState = val; } }, + inject: ['form'], computed: { classes () { return [ @@ -103,13 +104,13 @@ } ]; }, - form() { - let parent = this.$parent; - while (parent.$options.name !== 'iForm') { - parent = parent.$parent; - } - return parent; - }, + // form() { + // let parent = this.$parent; + // while (parent.$options.name !== 'iForm') { + // parent = parent.$parent; + // } + // return parent; + // }, fieldValue: { cache: false, get() { diff --git a/src/components/form/form.vue b/src/components/form/form.vue index 477b08fb..57b284a2 100644 --- a/src/components/form/form.vue +++ b/src/components/form/form.vue @@ -40,6 +40,9 @@ default: 'off' } }, + provide() { + return { form : this }; + }, data () { return { fields: []