* 采用inject方法,修正问题:当FormItem组件在slot里时,无法正确获取form组件
This commit is contained in:
parent
d45d2ee061
commit
4e31085656
2 changed files with 11 additions and 7 deletions
|
@ -92,6 +92,7 @@
|
||||||
this.validateState = val;
|
this.validateState = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
inject: ['form'],
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
return [
|
return [
|
||||||
|
@ -103,13 +104,13 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
form() {
|
// form() {
|
||||||
let parent = this.$parent;
|
// let parent = this.$parent;
|
||||||
while (parent.$options.name !== 'iForm') {
|
// while (parent.$options.name !== 'iForm') {
|
||||||
parent = parent.$parent;
|
// parent = parent.$parent;
|
||||||
}
|
// }
|
||||||
return parent;
|
// return parent;
|
||||||
},
|
// },
|
||||||
fieldValue: {
|
fieldValue: {
|
||||||
cache: false,
|
cache: false,
|
||||||
get() {
|
get() {
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
default: 'off'
|
default: 'off'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
provide() {
|
||||||
|
return { form : this };
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
fields: []
|
fields: []
|
||||||
|
|
Loading…
Add table
Reference in a new issue