-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fengyuanliang3
committed
Nov 7, 2020
1 parent
b15e4b4
commit 6ce6656
Showing
7 changed files
with
109 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export default { | ||
computed: { | ||
ignoreNodeWrappers() { | ||
return (this.options || {}).directComponents || [] | ||
} | ||
}, | ||
methods: { | ||
resolveField(field) { | ||
const renderField = { | ||
...field, | ||
children: [].concat(field.children) | ||
} | ||
|
||
this.registry.provider | ||
.useOptions({ ...this.options, registry: this.registry }) | ||
.execute(renderField, this.context) | ||
|
||
return renderField | ||
}, | ||
renderNode(h, field) { | ||
const { component, fieldOptions, key, children } = field | ||
|
||
return !this.ignoreNodeWrappers.includes(component) | ||
? h('v-jform-node', { | ||
slot: (fieldOptions || {}).slot, | ||
scopedSlots: (fieldOptions || {}).scopedSlots, | ||
props: { | ||
context: this.context, | ||
field: field, | ||
registry: this.registry, | ||
components: this.components, | ||
options: this.options | ||
} | ||
}) | ||
: h( | ||
this.components[component] || component, | ||
{ | ||
...fieldOptions, | ||
key: fieldOptions.key || key | ||
}, | ||
(children || []).map(child => this.renderNode(h, child)) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<template> | ||
<div> | ||
<v-jform | ||
:fields="fields" | ||
v-model="model" | ||
:params="params" | ||
:datasource="datasource" | ||
:components="components" | ||
:listeners="listeners" | ||
:options="options" | ||
></v-jform> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
params: {}, | ||
model: {}, | ||
components: {}, | ||
datasource: {}, | ||
listeners: [], | ||
fields: [ | ||
{ | ||
component: 'div', | ||
children: [ | ||
{ | ||
component: 'el-tabs', | ||
children: [ | ||
{ | ||
component: 'el-tab-pane', | ||
fieldOptions: { props: { label: 'tab1' } } | ||
}, | ||
{ | ||
component: 'el-tab-pane', | ||
fieldOptions: { props: { label: 'tab2' } } | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
options: { | ||
directComponents: ['el-tab-pane'] | ||
} | ||
} | ||
} | ||
} | ||
</script> |