Commit 4e31085656024415d21d3e4955ca3f590cde48fe
1 parent
d45d2ee0
* 采用inject方法,修正问题:当FormItem组件在slot里时,无法正确获取form组件
Showing
2 changed files
with
11 additions
and
7 deletions
Show diff stats
src/components/form/form-item.vue
... | ... | @@ -92,6 +92,7 @@ |
92 | 92 | this.validateState = val; |
93 | 93 | } |
94 | 94 | }, |
95 | + inject: ['form'], | |
95 | 96 | computed: { |
96 | 97 | classes () { |
97 | 98 | return [ |
... | ... | @@ -103,13 +104,13 @@ |
103 | 104 | } |
104 | 105 | ]; |
105 | 106 | }, |
106 | - form() { | |
107 | - let parent = this.$parent; | |
108 | - while (parent.$options.name !== 'iForm') { | |
109 | - parent = parent.$parent; | |
110 | - } | |
111 | - return parent; | |
112 | - }, | |
107 | + // form() { | |
108 | + // let parent = this.$parent; | |
109 | + // while (parent.$options.name !== 'iForm') { | |
110 | + // parent = parent.$parent; | |
111 | + // } | |
112 | + // return parent; | |
113 | + // }, | |
113 | 114 | fieldValue: { |
114 | 115 | cache: false, |
115 | 116 | get() { | ... | ... |