Commit 4e31085656024415d21d3e4955ca3f590cde48fe

Authored by BillyWang
1 parent d45d2ee0

* 采用inject方法,修正问题:当FormItem组件在slot里时,无法正确获取form组件

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() {
... ...
src/components/form/form.vue
... ... @@ -40,6 +40,9 @@
40 40 default: 'off'
41 41 }
42 42 },
  43 + provide() {
  44 + return { form : this };
  45 + },
43 46 data () {
44 47 return {
45 48 fields: []
... ...