溢出按钮

v-overflow-btn 用于使用户能够从列表中选择项目。 它具有 3 种变量:editable, overflowsegmented

用例

v-overflow-btn 用于创建选择列表

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. label="Overflow Btn"
  7. target="#dropdown-example-1"
  8. ></v-overflow-btn>
  9. </v-container>
  10. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图1

在为 items 属性使用对象时,您必须将 item-textitem-value 与对象上的现有属性关联。这些值默认为 textvalue,可以更改。

menu-propsauto 属性只支持默认输入样式。

API

从下面选择您想要的组件,并查看可用的属性、插槽、事件和函数。

Overflow buttons(溢出按钮) - 图2

实战场

template script


  1. <template>
  2. <v-row align="center">
  3. <v-row justify="space-around">
  4. <v-switch
  5. v-model="editable"
  6. class="ma-2"
  7. label="Editable"
  8. ></v-switch>
  9. <v-switch
  10. v-model="segmented"
  11. class="ma-2"
  12. label="Segmented"
  13. ></v-switch>
  14. <v-switch
  15. v-model="loading"
  16. class="ma-2"
  17. label="Loading"
  18. ></v-switch>
  19. <v-switch
  20. v-model="disabled"
  21. class="ma-2"
  22. label="Disabled"
  23. ></v-switch>
  24. <v-switch
  25. v-model="readonly"
  26. class="ma-2"
  27. label="Readonly"
  28. ></v-switch>
  29. <v-switch
  30. v-model="filled"
  31. class="ma-2"
  32. label="Filled"
  33. ></v-switch>
  34. <v-switch
  35. v-model="reverse"
  36. class="ma-2"
  37. label="Reverse"
  38. ></v-switch>
  39. <v-switch
  40. v-model="dense"
  41. class="ma-2"
  42. label="Dense"
  43. ></v-switch>
  44. <v-switch
  45. v-model="persistentHint"
  46. class="ma-2"
  47. label="Persistent hint"
  48. ></v-switch>
  49. <v-switch
  50. v-model="topMenu"
  51. class="ma-2"
  52. label="Menu to top"
  53. ></v-switch>
  54. </v-row>
  55. <v-container id="dropdown-playground">
  56. <v-overflow-btn
  57. class="my-2"
  58. :items="dropdownFont"
  59. :editable="editable"
  60. :segmented="segmented"
  61. :loading="loading"
  62. :disabled="disabled"
  63. :readonly="readonly"
  64. :filled="filled"
  65. :reverse="reverse"
  66. :dense="dense"
  67. :persistent-hint="persistentHint"
  68. :menu-props="topMenu ? 'top' : ''"
  69. hint="I'm a hint"
  70. label="Overflow Btn"
  71. target="#dropdown-playground"
  72. ></v-overflow-btn>
  73. </v-container>
  74. </v-row>
  75. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdownFont: [
  5. { text: 'Arial', callback: () => {} },
  6. { text: 'Calibri', callback: () => {} },
  7. { text: 'Courier', callback: () => {} },
  8. { text: 'Verdana', callback: () => {} },
  9. ],
  10. editable: false,
  11. segmented: false,
  12. loading: false,
  13. disabled: false,
  14. readonly: false,
  15. filled: false,
  16. reverse: false,
  17. dense: false,
  18. persistentHint: false,
  19. topMenu: false,
  20. }),
  21. }
  22. </script>

Overflow buttons(溢出按钮) - 图3

示例

下面是一些简单到复杂的例子。

计数器

您可以添加一个计数器到 v-overflow-btn 来控制最大字符计数

template script


  1. <template>
  2. <v-container id="dropdown-example-3">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_edit"
  6. label="Overflow Btn w/ counter"
  7. counter
  8. item-value="text"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_edit: [
  5. { text: '100%' },
  6. { text: '75%' },
  7. { text: '50%' },
  8. { text: '25%' },
  9. { text: '0%' },
  10. ],
  11. }),
  12. }
  13. </script>

Overflow buttons(溢出按钮) - 图4

禁用

v-overflow-btn 可以被禁用,以防止用户与它进行交互。

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. label="Overflow Btn w/ disabled"
  7. disabled
  8. target="#dropdown-example-1"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图5

密集

您可以使用 dense 属性来降低溢出按钮的高度并降低列表项的最大高度。

template script


  1. <template>
  2. <v-container>
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="items"
  6. label="Overflow Btn - Dense"
  7. dense
  8. ></v-overflow-btn>
  9. </v-container>
  10. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. items: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图6

可编辑

editable v-overflow-btn 可以直接编辑,就像 v-text-field 一样

template script


  1. <template>
  2. <v-container id="dropdown-example-3">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_edit"
  6. label="Overflow Btn w/ editable"
  7. editable
  8. item-value="text"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_edit: [
  5. { text: '100%' },
  6. { text: '75%' },
  7. { text: '50%' },
  8. { text: '25%' },
  9. { text: '0%' },
  10. ],
  11. }),
  12. }
  13. </script>

Overflow buttons(溢出按钮) - 图7

填充的

文本框可以使用替代的样式设计,但是这种模式下不支持附加或者前置图标属性。

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. label="Overflow Btn - filled"
  7. filled
  8. target="#dropdown-example-1"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图8

Material Dashboard Pro

Vuetify Material Dashboard PRO is a beautiful theme built over Vuetify, Vuex and Vuejs. Vuetify Material Dashboard PRO is the official Vuejs version of the Original Material Dashboard PRO.

ads by Vuetify

](https://www.creative-tim.com/product/vuetify-material-dashboard-pro?ref=vuetifyjs.com&partner=116160)

提示

您可以使用 hint 属性为用户添加提示

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. menu-props="top"
  7. label="Overflow Btn w/ hint"
  8. hint="Select font"
  9. target="#dropdown-example-1"
  10. ></v-overflow-btn>
  11. </v-container>
  12. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图9

加载

v-overflow-btn 可以处于 loading 状态,并且在其下方具有线性进度条

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. label="Overflow Btn w/ loading"
  7. loading
  8. target="#dropdown-example-1"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图10

菜单属性

你可以使用 menu-props 属性设置底部的 v-menu 属性

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. menu-props="top"
  7. label="Overflow Btn w/ menu-props"
  8. target="#dropdown-example-1"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图11

只读

v-overflow-btn 可以设置为 readonly 模式,它将处于非活动状态,但不会改变颜色

template script


  1. <template>
  2. <v-container id="dropdown-example-1">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_font"
  6. label="Overflow Btn w/ readonly"
  7. readonly
  8. target="#dropdown-example-1"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_font: ['Arial', 'Calibri', 'Courier', 'Verdana'],
  5. }),
  6. }
  7. </script>

Overflow buttons(溢出按钮) - 图12

分段

segmented v-overflow-btn 在内容和图标之间有一个附加的分隔符

template script


  1. <template>
  2. <v-container id="dropdown-example-2">
  3. <v-overflow-btn
  4. class="my-2"
  5. :items="dropdown_icon"
  6. label="Overflow Btn w/ segmented"
  7. segmented
  8. target="#dropdown-example-2"
  9. ></v-overflow-btn>
  10. </v-container>
  11. </template>
  1. <script>
  2. export default {
  3. data: () => ({
  4. dropdown_icon: [
  5. { text: 'list', callback: () => console.log('list') },
  6. { text: 'favorite', callback: () => console.log('favorite') },
  7. { text: 'delete', callback: () => console.log('delete') },
  8. ],
  9. }),
  10. }
  11. </script>

Overflow buttons(溢出按钮) - 图13