File tree Expand file tree Collapse file tree 8 files changed +159
-2
lines changed Expand file tree Collapse file tree 8 files changed +159
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ import LayoutFlexible from './layout-flexible'
2626import SlotFront from ' ./slot-front'
2727import SlotRear from ' ./slot-rear'
2828import SlotSlot from ' ./slot-slot'
29+ // 自定义组件
30+ import CustomInput from ' ./custom-input'
31+ // 动态属性
32+ import DynamicInput from ' ./dynamic-input'
2933
3034export default {
3135 props: {
@@ -44,7 +48,9 @@ export default {
4448 LayoutFlexible,
4549 SlotFront,
4650 SlotRear,
47- SlotSlot
51+ SlotSlot,
52+ CustomInput,
53+ DynamicInput
4854 },
4955 data () {
5056 return {
Original file line number Diff line number Diff line change 1+ <template >
2+ <el-form >
3+ <schema-form
4+ :model =" model"
5+ :schema =" schema"
6+ >
7+ </schema-form >
8+ </el-form >
9+ </template >
10+
11+ <script >
12+ export default {
13+ data () {
14+ return {
15+ model: { num: 1 },
16+ schema: [
17+ [
18+ {
19+ type: ' CustomNumber' ,
20+ prop: ' num' ,
21+ formItem: { label: ' 自定义组件' },
22+ attrs: { precision: 2 , step: 0.1 , max: 10 }
23+ }
24+ ]
25+ ]
26+ }
27+ }
28+ }
29+ </script >
30+
31+ <style scoped>
32+
33+ </style >
Original file line number Diff line number Diff line change 1+
2+ <template >
3+ <el-input-number
4+ v-model =" bindVal"
5+ v-bind =" attrsAll"
6+ v-on =" onEvents"
7+ ></el-input-number >
8+ </template >
9+
10+ <script >
11+
12+ import { FormMixin } from ' ../../../../src/index'
13+
14+ export default {
15+ name: ' CustomNumber' ,
16+ mixins: [FormMixin]
17+ }
18+
19+ </script >
20+
21+ <style scoped>
22+
23+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <el-form label-width =" 80px" >
3+ <schema-form
4+ :model =" model"
5+ :schema =" schema"
6+ >
7+ </schema-form >
8+ </el-form >
9+ </template >
10+
11+ <script >
12+ export default {
13+ data () {
14+ return {
15+ model: {
16+ name: ' ' ,
17+ editable: true
18+ }
19+ }
20+ },
21+ computed: {
22+ schema () {
23+ return [
24+ [
25+ {
26+ type: ' switch' ,
27+ prop: ' editable' ,
28+ formItem: { label: ' 可编辑' }
29+ }
30+ ],
31+ [
32+ {
33+ type: ' input' ,
34+ prop: ' name' ,
35+ formItem: { label: ' 姓名' },
36+ dynamicAttrs: { disabled: ! this .model .editable }
37+ }
38+ ]
39+ ]
40+ }
41+ }
42+ }
43+ </script >
44+
45+ <style scoped>
46+
47+ </style >
Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ module.exports = {
4242 '/guide/component/SchemaForm' ,
4343 [ '/guide/component/schema' , 'schema 详解' ] ,
4444 [ '/guide/component/layout' , 'layout 布局' ] ,
45- [ '/guide/component/slot' , 'slot 插槽' ]
45+ [ '/guide/component/slot' , 'slot 插槽' ] ,
46+ [ '/guide/component/dynamic' , 'dynamicAttrs 动态属性' ] ,
47+ [ '/guide/component/custom' , '自定义组件' ]
4648 ]
4749 }
4850 ]
Original file line number Diff line number Diff line change 11import SchemaForm from '../../src/index.js'
22import ElementUI from "element-ui"
3+ import CustomNumber from './components/custom/custom-number.vue'
4+
35import "element-ui/lib/theme-chalk/index.css"
46import '@vuepress/theme-default'
57
68export default ( { Vue } ) => {
79 Vue . use ( SchemaForm )
810 Vue . use ( ElementUI )
11+ Vue . component ( 'CustomNumber' , CustomNumber )
912}
Original file line number Diff line number Diff line change 1+ ### 自定义组件
2+
3+ #### 定义组件
4+ ``` js
5+ < template>
6+ < el- input- number
7+ v- model= " bindVal"
8+ v- bind= " attrsAll"
9+ v- on= " onEvents"
10+ >< / el- input- number>
11+ < / template>
12+
13+ < script>
14+ import { FormMixin } from ' @vueblocks/element-schema-form'
15+ export default {
16+ name: ' CustomNumber' ,
17+ mixins: [FormMixin]
18+ }
19+ < / script>
20+ ```
21+
22+ #### main.js 全局引入组件
23+ ``` js
24+ import ElementUI from ' element-ui'
25+ import ' element-ui/lib/theme-chalk/index.css'
26+ import SchemaForm from ' @vueblocks/element-schema-form'
27+ import CustomNumber from ' @/components/custom-number.vue'
28+
29+ Vue .use (ElementUI)
30+ Vue .use (SchemaForm)
31+ Vue .component (' CustomNumber' , CustomNumber)
32+ ```
33+
34+ #### 使用自定义组件
35+
36+ <code-contain compName =" CustomInput " link =" https://codesandbox.io/s/zidingyizujian-qk1h8?fontsize=14 " >
37+ <<< @/docs/.vuepress/components/custom-input.vue
38+ </code-contain >
Original file line number Diff line number Diff line change 1+ #### 使用动态属性联动
2+
3+ <code-contain compName =" DynamicInput " link =" https://codesandbox.io/s/dongtaishuxing-urlvq?fontsize=14 " >
4+ <<< @/docs/.vuepress/components/dynamic-input.vue
5+ </code-contain >
You can’t perform that action at this time.
0 commit comments