forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic.vue
More file actions
56 lines (48 loc) · 1.02 KB
/
Basic.vue
File metadata and controls
56 lines (48 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
<div class="q-pa-md row justify-center">
<div
v-ripple
class="relative-position container flex flex-center text-white"
:class="classes"
>
Click/tap me
</div>
</div>
</template>
<script>
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
const colors = [
'primary', 'amber', 'secondary', 'orange', 'accent',
'lime', 'cyan', 'purple', 'brown', 'blue'
]
export default {
setup () {
const color = ref(colors[ 0 ])
const index = ref(0)
let timer
onMounted(() => {
timer = setInterval(() => {
index.value = (index.value + 1) % colors.length
color.value = colors[ index.value ]
}, 3000)
})
onBeforeUnmount(() => {
clearTimeout(timer)
})
return {
color,
index,
classes: computed(() => `bg-${color.value}`)
}
}
}
</script>
<style lang="sass" scoped>
.container
border-radius: 3px
cursor: pointer
transition: background 1.5s
height: 150px
width: 80%
max-width: 500px
</style>