- Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathSetupScript.vue
46 lines (33 loc) · 706 Bytes
/
SetupScript.vue
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
<script setup>
import { computed, reactive, ref } from'vue'
import { useStore } from'vuex'
import { useRouter } from'vue-router'
importChildfrom'./Child.vue'
constmyObj=reactive({
foo:'bar',
})
constcount=ref(0)
constdouble=computed(() =>count.value*2)
constanswer=42
conststate2=reactive({
n:ref(0),
})
functiononClick() {
count.value++
}
constthrows=computed(() => {
thrownewError('oops')
})
conststore=useStore()
constthrowsWithVuex=computed(() =>store.getters.throws)
constrouter=useRouter()
</script>
<template>
{{ count }}
{{ double }}
<button@click="onClick">
+1
</button>
<Child />
<pre>{{ state2 }}</pre>
</template>