* 采用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;
|
||||
}
|
||||
},
|
||||
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() {
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
default: 'off'
|
||||
}
|
||||
},
|
||||
provide() {
|
||||
return { form : this };
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
fields: []
|
||||
|
|
Loading…
Add table
Reference in a new issue