File tree Expand file tree Collapse file tree 9 files changed +148
-7
lines changed Expand file tree Collapse file tree 9 files changed +148
-7
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ import AddItem from './add-item'
2222import LayoutGutter from ' ./layout-gutter'
2323import LayoutOffset from ' ./layout-offset'
2424import LayoutFlexible from ' ./layout-flexible'
25-
25+ // slot 布局
26+ import SlotFront from ' ./slot-front'
27+ import SlotRear from ' ./slot-rear'
28+ import SlotSlot from ' ./slot-slot'
2629
2730export default {
2831 props: {
@@ -38,7 +41,10 @@ export default {
3841 AddItem,
3942 LayoutGutter,
4043 LayoutOffset,
41- LayoutFlexible
44+ LayoutFlexible,
45+ SlotFront,
46+ SlotRear,
47+ SlotSlot
4248 },
4349 data () {
4450 return {
Original file line number Diff line number Diff line change 1+ <template >
2+ <el-form size =" small" >
3+ <schema-form
4+ :model =" model"
5+ :schema =" schema"
6+ >
7+ <div slot =" name" >
8+ <span >姓名</span >
9+ <el-tooltip content =" 请输入用户姓名" placement =" right" >
10+ <i class =" el-icon-warning" ></i >
11+ </el-tooltip >
12+ </div >
13+ </schema-form >
14+ </el-form >
15+ </template >
16+
17+ <script >
18+ export default {
19+ data () {
20+ return {
21+ model: {
22+ name: ' '
23+ },
24+ schema: [
25+ [
26+ {
27+ type: ' input' ,
28+ prop: ' name' ,
29+ formItem: { label: ' ' },
30+ frontSlot: ' name'
31+ }
32+ ]
33+ ]
34+ }
35+ }
36+ }
37+ </script >
38+
39+ <style scoped>
40+
41+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <el-form size =" small" >
3+ <schema-form
4+ :model =" model"
5+ :schema =" schema"
6+ >
7+ <div slot =" name" class =" text-area" >
8+ <span class =" text-area__num" >{{model.name.length}}</span >字
9+ </div >
10+ </schema-form >
11+ </el-form >
12+ </template >
13+
14+ <script >
15+
16+ export default {
17+ data () {
18+ return {
19+ model: {
20+ name: ' '
21+ },
22+ schema: [
23+ [
24+ {
25+ type: ' input' ,
26+ prop: ' name' ,
27+ formItem: { label: ' 姓名' },
28+ rearSlot: ' name'
29+ }
30+ ]
31+ ]
32+ }
33+ }
34+ }
35+ </script >
36+
37+ <style scoped>
38+ .text-area {
39+ text-align : right ;
40+ }
41+ .text-area__num {
42+ margin-right :5px ;
43+ }
44+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <el-form size =" small" >
3+ <schema-form
4+ :model =" model"
5+ :schema =" schema"
6+ >
7+ <el-form-item label =" 活动名称" slot =" name" >
8+ <el-input v-model =" model.name" ></el-input >
9+ </el-form-item >
10+ </schema-form >
11+ </el-form >
12+ </template >
13+
14+ <script >
15+ export default {
16+ data () {
17+ return {
18+ model: {
19+ name: ' '
20+ },
21+ schema: [
22+ [{ slot: ' name' }]
23+ ]
24+ }
25+ }
26+ }
27+ </script >
28+
29+ <style scoped>
30+
31+ </style >
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ module.exports = {
4141 children : [
4242 '/guide/component/SchemaForm' ,
4343 [ '/guide/component/schema' , 'schema 详解' ] ,
44- [ '/guide/component/layout' , 'layout 布局' ]
44+ [ '/guide/component/layout' , 'layout 布局' ] ,
45+ [ '/guide/component/slot' , 'slot 插槽' ]
4546 ]
4647 }
4748 ]
Original file line number Diff line number Diff line change @@ -113,12 +113,11 @@ on: {
113113}
114114```
115115
116- ## 插槽 slot
116+ ## 插槽 slot
117117
118118参数|说明|
119119:--|:--
120120slot| 自定义完整组件
121121frontSlot| 定义element 组件前的插槽
122- compSlot| 定义element 组件内的插槽
123122rearSlot| 定义element 组件后的插槽
124123
Original file line number Diff line number Diff line change 1+ ### 插槽
2+
3+ <code-contain compName =" SlotSlot " link =" https://codesandbox.io/s/chacao-697j3?fontsize=14 " >
4+ <<< @/docs/.vuepress/components/slot-slot.vue
5+ </code-contain >
6+
7+ ### 前置插槽
8+
9+ <code-contain compName =" SlotFront " link =" https://codesandbox.io/s/qianzhichacao-5phtv?fontsize=14 " >
10+ <<< @/docs/.vuepress/components/slot-front.vue
11+ </code-contain >
12+
13+ ### 后置插槽
14+
15+ <code-contain compName =" SlotRear " link =" https://codesandbox.io/s/houzhichacao-vrkco?fontsize=14 " >
16+ <<< @/docs/.vuepress/components/slot-rear.vue
17+ </code-contain >
Original file line number Diff line number Diff line change 1818 :model =" model"
1919 :options =" options"
2020 v-on =" $listeners"
21- />
21+ >
22+ <slot v-if =" col.frontSlot" :name =" col.frontSlot" :slot =" col.frontSlot" ></slot >
23+ <slot v-if =" col.rearSlot" :name =" col.rearSlot" :slot =" col.rearSlot" ></slot >
24+ </schema-form-item >
2225 </template >
2326 </el-col >
2427 </template >
Original file line number Diff line number Diff line change 1212 :onEvents =" col.on"
1313 :options =" options[col.prop]"
1414 >
15- <slot :name =" col.compSlot" v-if =" col.compSlot" ></slot >
1615 </component >
1716 <slot :name =" col.rearSlot" v-if =" col.rearSlot" ></slot >
1817 </el-form-item >
You can’t perform that action at this time.
0 commit comments