1
1
<template >
2
2
<h1 >{{ msg }}</h1 >
3
3
4
- <p >
5
- <a href =" https://vitejs.dev/guide/features.html" target =" _blank" >Vite Documentation</a > |
6
- <a href =" https://v3.vuejs.org/" target =" _blank" >Vue 3 Documentation</a >
7
- </p >
4
+ <label >
5
+ <input type =" checkbox" v-model =" useScriptSetup" /> Use
6
+ <code >< ; script setup> ; </code >
7
+ </label >
8
+ <label >
9
+ <input type =" checkbox" v-model =" useTsPlugin" /> Provide types for
10
+ <code >*.vue</code > imports
11
+ </label >
8
12
9
13
<p >
10
14
Recommended IDE setup:
11
15
<a href =" https://code.visualstudio.com/" target =" _blank" >VSCode</a >
12
16
+
13
- <a
14
- href =" https://marketplace.visualstudio.com/items?itemName=octref.vetur"
15
- target =" _blank"
16
- >Vetur</a >
17
- +
18
- <a
19
- href =" https://marketplace.visualstudio.com/items?itemName=znck.vue-language-features"
20
- target =" _blank"
21
- >Vue DX</a >
17
+ <template v-if =" ! useScriptSetup " >
18
+ <a
19
+ href =" https://marketplace.visualstudio.com/items?itemName=octref.vetur"
20
+ target =" _blank"
21
+ >Vetur</a >
22
+ +
23
+ <a
24
+ href =" https://marketplace.visualstudio.com/items?itemName=znck.vue-language-features"
25
+ target =" _blank"
26
+ >Vue DX</a >
27
+ </template >
28
+ <template v-else >
29
+ <a href =" https://github.com/johnsoncodehk/volar" target =" _blank" >Volar</a >
30
+ </template >
22
31
</p >
23
- <p >
24
- If using < ; script setup> ; : use
25
- <a
26
- href =" https://github.com/johnsoncodehk/volar"
27
- target =" _blank"
28
- >Volar</a > instead (and disable Vetur)
29
- </p >
30
- <p >
31
- <b style =" color :red " >Make sure to use workspace version of TypeScript!!!</b >
32
- <br />This leverages the
33
- <code >@vuex/typescript-plugin-vue</code > to provide types for `*.vue` imports.
34
- <br />1. Open
32
+ <p v-if =" useTsPlugin" >
33
+ tsconfig setup:
34
+ <br />1. Install and add
35
+ <code >@vuex/typescript-plugin-vue</code > to tsconfig plugins
36
+ <br />2. Delete shims-vue.d.ts
37
+ <br />3. Open
35
38
<code >src/main.ts</code > in VSCode
36
- <br />2 . Open VSCode command input
37
- <br />3 . Search and run "Select TypeScript version" -> "Use workspace version"
39
+ <br />4 . Open VSCode command input
40
+ <br />5 . Search and run "Select TypeScript version" -> "Use workspace version"
38
41
</p >
39
42
<button @click =" count++" >count is: {{ count }}</button >
40
43
<p >
41
44
Edit
42
45
<code >components/HelloWorld.vue</code > to test hot module replacement.
43
46
</p >
47
+
48
+ <p >
49
+ <a href =" https://vitejs.dev/guide/features.html" target =" _blank" >Vite Docs</a > |
50
+ <a href =" https://v3.vuejs.org/" target =" _blank" >Vue 3 Docs</a >
51
+ </p >
44
52
</template >
45
53
46
54
<script lang="ts">
47
55
import { ref , defineComponent } from ' vue'
48
-
49
56
export default defineComponent ({
50
57
name: ' HelloWorld' ,
51
58
props: {
@@ -56,7 +63,9 @@ export default defineComponent({
56
63
},
57
64
setup : () => {
58
65
const count = ref (0 )
59
- return { count }
66
+ const useScriptSetup = ref (false );
67
+ const useTsPlugin = ref (false );
68
+ return { count , useScriptSetup , useTsPlugin }
60
69
}
61
70
})
62
71
</script >
@@ -65,4 +74,16 @@ export default defineComponent({
65
74
a {
66
75
color : #42b983 ;
67
76
}
68
- </style >
77
+
78
+ label {
79
+ margin : 0 0.5em ;
80
+ font-weight : bold ;
81
+ }
82
+
83
+ code {
84
+ background-color : #eee ;
85
+ padding : 2px 4px ;
86
+ border-radius : 4px ;
87
+ color : #304455 ;
88
+ }
89
+ </style >
0 commit comments