返回 slidev
VClick.ts
根目录 / packages / client / builtin / VClick.ts
1 /**
2 * <v-click/> click animations component
3 *
4 * Learn more: https://sli.dev/guide/animations.html#click-animation
5 */
6
7 import type { PropType, VNode } from 'vue'
8 import { defineComponent, h, Text } from 'vue'
9 import { CLICKS_MAX } from '../constants'
10 import VClicks from './VClicks'
11
12 export default defineComponent({
13 props: {
14 at: {
15 type: [Number, String],
16 default: '+1',
17 },
18 hide: {
19 type: Boolean,
20 default: false,
21 },
22 /**
23 * @deprecated use `animation` instead
24 */
25 fade: {
26 type: Boolean,
27 default: false,
28 },
29 animation: {
30 type: String,
31 default: undefined,
32 },
33 wrapText: {
34 type: Function as PropType<(text: VNode) => VNode>,
35 default: (text: VNode) => h('span', text),
36 },
37 },
38 render() {
39 return h(
40 VClicks,
41 {
42 every: CLICKS_MAX,
43 at: this.at,
44 hide: this.hide,
45 fade: this.fade,
46 animation: this.animation,
47 handleSpecialElements: false,
48 },
49 {
50 default: () =>
51 this.$slots.default?.().map(v =>
52 v.type === Text
53 ? this.wrapText(v)
54 : v,
55 ),
56 },
57 )
58 },
59 })
60
60 lines TYPESCRIPT