波纹指令

v-ripple 指令被用于显示用户的操作。它可以应用于任何块级元素。许多组件都带有内置的波纹指令,比如 v-btnv-tabs-item 等等。

用例

只要在组件或 HTML 元素上使用 v-ripple 指令,就可以启用基本的波纹功能

template


  1. <template>
  2. <div
  3. v-ripple
  4. class="text-center elevation-2 pa-12 headline"
  5. >
  6. HTML element with v-ripple
  7. </div>
  8. </template>

Ripples(波纹) - 图1

API

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

Ripples(波纹) - 图2

示例

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

自定义色彩

您可以使用辅助器类改变波纹的颜色。

template


  1. <template>
  2. <v-list>
  3. <v-list-item
  4. v-for="color in ['primary', 'secondary', 'info', 'success', 'warning', 'error']"
  5. :key="color"
  6. v-ripple="{ class: `${color}--text` }"
  7. >
  8. <v-list-item-title>Item with "{{ color }}" class</v-list-item-title>
  9. </v-list-item>
  10. </v-list>
  11. </template>

Ripples(波纹) - 图3

居中波纹

当使用 center 选项时,始终会从目标的中心处产生波纹。

template


  1. <template>
  2. <div
  3. v-ripple="{ center: true }"
  4. class="text-center elevation-2 pa-12 headline"
  5. >
  6. HTML element with centered ripple
  7. </div>
  8. </template>

Ripples(波纹) - 图4

组件中的波纹

有些组件提供了 ripple 属性,允许您控制波纹效果。 您可以使用 classcenter 选项关闭它或提供自定义行为。

template


  1. <template>
  2. <v-row
  3. class="py-12"
  4. justify="space-around"
  5. >
  6. <v-btn
  7. color="primary"
  8. >
  9. With ripple (default)
  10. </v-btn>
  11. <v-btn
  12. :ripple="false"
  13. color="primary"
  14. >
  15. Without ripple
  16. </v-btn>
  17. <v-btn
  18. :ripple="{ center: true }"
  19. color="primary"
  20. >
  21. With centered ripple
  22. </v-btn>
  23. <v-btn
  24. :ripple="{ class: 'red--text' }"
  25. text
  26. >
  27. With red ripple
  28. </v-btn>
  29. </v-row>
  30. </template>

Ripples(波纹) - 图5