File tree 2 files changed +63
-0
lines changed
2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 515
515
```
516
516
:::
517
517
518
+ ### 扩展插槽
519
+
520
+ 选项列表底部扩展内容
521
+ :::demo 扩展插槽可以插入自己需要的功能按钮。
522
+ ``` html
523
+ <template >
524
+ <div >
525
+ <el-select v-model =" value" placeholder =" 请选择" >
526
+ <el-option
527
+ v-for =" item in cities"
528
+ :key =" item.value"
529
+ :label =" item.label"
530
+ :value =" item.value" >
531
+ </el-option >
532
+ <div slot =" extra" >
533
+ <el-button type =" text" @click =" handleRefresh" style =" width : 100% ;" >
534
+ 刷新城市列表
535
+ </el-button >
536
+ </div >
537
+ </el-select >
538
+ </div >
539
+ </template >
540
+
541
+ <script >
542
+ export default {
543
+ data () {
544
+ return {
545
+ cities: [{
546
+ value: ' Beijing' ,
547
+ label: ' 北京'
548
+ }, {
549
+ value: ' Shanghai' ,
550
+ label: ' 上海'
551
+ }, {
552
+ value: ' Nanjing' ,
553
+ label: ' 南京'
554
+ }, {
555
+ value: ' Chengdu' ,
556
+ label: ' 成都'
557
+ }, {
558
+ value: ' Shenzhen' ,
559
+ label: ' 深圳'
560
+ }, {
561
+ value: ' Guangzhou' ,
562
+ label: ' 广州'
563
+ }],
564
+ value: ' '
565
+ };
566
+ },
567
+ methods: {
568
+ handleRefresh () {
569
+ // 重新请求获取 cities 数据
570
+ },
571
+ }
572
+ }
573
+ </script >
574
+ ```
575
+ :::
576
+
518
577
::: tip
519
578
如果 Select 的绑定值为对象类型,请务必指定 ` value-key ` 作为它的唯一性标识。
520
579
:::
565
624
| — | Option 组件列表 |
566
625
| prefix | Select 组件头部内容 |
567
626
| empty | 无选项时的列表 |
627
+ | extra | 选项列表底部扩展内容 |
568
628
569
629
### Option Group Attributes
570
630
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
Original file line number Diff line number Diff line change 122
122
</el-option >
123
123
<slot ></slot >
124
124
</el-scrollbar >
125
+ <template v-if =" $slots .extra " >
126
+ <slot name =" extra" ></slot >
127
+ </template >
125
128
<template v-if =" emptyText && (! allowCreate || loading || (allowCreate && options .length === 0 ))" >
126
129
<slot name =" empty" v-if =" $slots.empty" ></slot >
127
130
<p class =" el-select-dropdown__empty" v-else >
You can’t perform that action at this time.
0 commit comments