Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 9dc0cc6

Browse files
authored
fix: examples and playground (#96)
1 parent 84983c3 commit 9dc0cc6

32 files changed

+230
-181
lines changed
File renamed without changes.
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
<template>
2-
<div>
3-
<h3>{{ msg }}, {{ name }}</h3>
4-
<button @click="inc">
5-
Inc
6-
</button>
7-
<div>{{ count }} x 2 = {{ doubled }}</div>
8-
<button @click="dec()" v-html="decText" />
9-
</div>
10-
</template>
111

2+
<script lang="ts">
3+
/* eslint-disable import/first */
4+
export default {
5+
name: 'App',
6+
}
7+
</script>
128
<script setup lang="ts">
13-
import { ref, computed, watch } from '@vue/composition-api'
9+
import { computed, ref, watch } from '@vue/composition-api'
1410
15-
const props = withDefaults(defineProps<{ msg: string; name: string | number }>(), { msg: 'Hello' })
16-
const emit = defineEmits(['update'])
11+
withDefaults(defineProps<{ msg: string; name: string | number }>(), { msg: 'Hello' })
12+
const emit = defineEmits<{
13+
(event: 'update', value: number): void
14+
}>()
1715
1816
const count = ref(0)
1917
const doubled = computed(() => count.value * 2)
@@ -30,9 +28,13 @@ const decText = '<b>Dec</b>'
3028
3129
watch(count, value => emit('update', value))
3230
</script>
33-
34-
<script lang="ts">
35-
export default {
36-
name: 'App'
37-
}
38-
</script>
31+
<template>
32+
<div>
33+
<h3>{{ msg }}, {{ name }}</h3>
34+
<button @click="inc">
35+
Inc
36+
</button>
37+
<div>{{ count }} x 2 = {{ doubled }}</div>
38+
<button @click="dec()" v-html="decText" />
39+
</div>
40+
</template>

examples/nuxt/pages/index.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
<template>
2-
<div>
3-
<hello-world name="Vue 2" @update="onUpdate" />
4-
</div>
5-
</template>
61

72
<script setup lang="ts">
83
import HelloWorld from '../components/HelloWorld.vue'
94
105
function onUpdate(e: any) {
6+
// eslint-disable-next-line no-console
117
console.log(e)
128
}
139
</script>
10+
<template>
11+
<div>
12+
<HelloWorld name="Vue 2" @update="onUpdate" />
13+
</div>
14+
</template>

examples/nuxt/shims-vue.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="unplugin-vue2-script-setup/shims.js" />

examples/nuxt/tsconfig.json

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,20 @@
99
"DOM"
1010
],
1111
"esModuleInterop": true,
12-
"skipLibCheck": true,
12+
"skipLibCheck": false,
1313
"allowJs": true,
1414
"sourceMap": true,
1515
"strict": true,
1616
"noEmit": true,
17-
"baseUrl": ".",
18-
"paths": {
19-
"~/*": [
20-
"./*"
21-
],
22-
"@/*": [
23-
"./*"
24-
]
25-
},
2617
"types": [
2718
"@types/node",
28-
"@nuxt/types",
29-
"unplugin-vue2-script-setup/types"
19+
"@nuxt/types"
3020
]
3121
},
3222
"exclude": [
3323
"node_modules"
34-
]
24+
],
25+
"vueCompilerOptions": {
26+
"experimentalCompatMode": 2
27+
}
3528
}

examples/vue-cli/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"lint": "vue-cli-service lint"
88
},
99
"dependencies": {
10+
"@vue/composition-api": "^1.4.3",
1011
"core-js": "^3.20.1",
11-
"vue": "^2.6.11"
12+
"vue": "^2.6.14"
1213
},
1314
"devDependencies": {
1415
"@vue/cli-plugin-babel": "^4.5.15",
@@ -18,5 +19,8 @@
1819
"unplugin-vue2-script-setup": "workspace:*",
1920
"vue-template-compiler": "^2.6.14",
2021
"vue-tsc": "^0.30.1"
22+
},
23+
"vueCompilerOptions": {
24+
"experimentalCompatMode": 2
2125
}
2226
}

examples/vue-cli/src/App.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
<script setup lang="ts">
2+
import HelloWorld from './components/HelloWorld.vue'
3+
</script>
14
<template>
25
<div id="app">
36
<HelloWorld msg="Welcome to Your Vue.js App" />
47
</div>
58
</template>
6-
7-
<script setup lang="ts">
8-
import HelloWorld from './components/HelloWorld.vue'
9-
</script>
10-
119
<style>
1210
#app {
1311
font-family: Avenir, Helvetica, Arial, sans-serif;

examples/vue-cli/src/components/HelloWorld.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
msg: string
4+
}>()
5+
</script>
16
<template>
27
<div class="hello">
38
<h1>{{ msg }}</h1>
@@ -28,13 +33,6 @@
2833
</ul>
2934
</div>
3035
</template>
31-
32-
<script setup lang="ts">
33-
defineProps({
34-
msg: String,
35-
})
36-
</script>
37-
3836
<style scoped>
3937
h3 {
4038
margin: 40px 0 0;

examples/vue-cli/src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import Vue from 'vue'
2-
import VueCompostionAPI from '@vue/composition-api'
2+
import VueCompostionAPI, { createApp, h } from '@vue/composition-api'
33
import App from './App.vue'
44

55
Vue.config.productionTip = false
66
Vue.use(VueCompostionAPI)
77

8-
const app = new Vue({ render: h => h(App as any) })
8+
const app = createApp({
9+
render: () => h(App),
10+
})
911

10-
app.$mount('#app')
12+
app.mount('#app')

examples/vue-cli/src/shims-vue.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
declare module '*.vue' {
2-
import Vue from 'vue'
3-
export default Vue
4-
}
1+
/// <reference types="unplugin-vue2-script-setup/shims.js" />

0 commit comments

Comments
 (0)