-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add basic counter examples (#453)
* Basic counter example * Basic counter example * Basic counter example * Updated readme * Lint fix * purged package-lock.json files * Update examples/options-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/composition-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/composition-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/composition-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/composition-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/class-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/options-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/composition-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io> * Update examples/composition-api/basic/pages/index.vue Co-authored-by: Kevin Marrec <kevin@marrec.io>
- Loading branch information
1 parent
1a2c82b
commit a1add07
Showing
16 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Nuxt TypeScript with Class API (basic) | ||
|
||
https://typescript.nuxtjs.org/examples/class-api/basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
buildModules: ['@nuxt/typescript-build'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "example-class-api-basic", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"nuxt": "latest", | ||
"vue-class-component": "latest", | ||
"vue-property-decorator": "latest" | ||
}, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"generate": "nuxt generate", | ||
"post-update": "yarn upgrade --latest" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/types": "latest", | ||
"@nuxt/typescript-build": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<div class="container"> | ||
<button @click="increment"> | ||
Increment | ||
</button> | ||
<p>Counter : {{ counter }}</p> | ||
<button @click="decrement"> | ||
Decrement | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Vue, Component } from 'vue-property-decorator' | ||
@Component | ||
export default class ClassAPICounter extends Vue { | ||
counter = 0 | ||
increment () { | ||
this.counter++ | ||
} | ||
decrement () { | ||
this.counter-- | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"lib": [ | ||
"ESNext", | ||
"ESNext.AsyncIterable", | ||
"DOM" | ||
], | ||
"esModuleInterop": true, | ||
"experimentalDecorators": true, | ||
"allowJs": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": [ | ||
"./*" | ||
], | ||
"@/*": [ | ||
"./*" | ||
] | ||
}, | ||
"types": [ | ||
"@nuxt/types" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Nuxt TypeScript with Composition API (basic) | ||
|
||
https://typescript.nuxtjs.org/examples/composition-api/basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
buildModules: ['@nuxt/typescript-build'], | ||
plugins: ['~/plugins/composition-api'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "example-composition-api-basic", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@vue/composition-api": "latest", | ||
"nuxt": "latest" | ||
}, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"generate": "nuxt generate", | ||
"post-update": "yarn upgrade --latest" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/types": "latest", | ||
"@nuxt/typescript-build": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<div class="container"> | ||
<button @click="increment"> | ||
Increment | ||
</button> | ||
<p>Counter : {{ counter }}</p> | ||
<button @click="decrement"> | ||
Decrement | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref } from '@vue/composition-api' | ||
export default defineComponent({ | ||
setup () { | ||
const counter = ref(0) | ||
const increment = () => counter.value++ | ||
const decrement = () => counter.value-- | ||
return { | ||
counter, | ||
increment, | ||
decrement | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style> | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Vue from 'vue' | ||
import VueCompositionApi from '@vue/composition-api' | ||
|
||
Vue.use(VueCompositionApi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"lib": [ | ||
"ESNext", | ||
"ESNext.AsyncIterable", | ||
"DOM" | ||
], | ||
"esModuleInterop": true, | ||
"allowJs": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": [ | ||
"./*" | ||
], | ||
"@/*": [ | ||
"./*" | ||
] | ||
}, | ||
"types": [ | ||
"@nuxt/types" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Nuxt TypeScript with Options API (basic) | ||
|
||
https://typescript.nuxtjs.org/examples/options-api/basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
buildModules: ['@nuxt/typescript-build'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "example-options-api-basic", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"nuxt": "latest" | ||
}, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"generate": "nuxt generate", | ||
"post-update": "yarn upgrade --latest" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/types": "latest", | ||
"@nuxt/typescript-build": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<div class="container"> | ||
<button @click="increment"> | ||
Increment | ||
</button> | ||
<p>Counter : {{ counter }}</p> | ||
<button @click="decrement"> | ||
Decrement | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
data () { | ||
return { | ||
counter: 0 | ||
} | ||
}, | ||
methods: { | ||
increment (): void { | ||
this.counter++ | ||
}, | ||
decrement (): void { | ||
this.counter-- | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style> | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"lib": [ | ||
"ESNext", | ||
"ESNext.AsyncIterable", | ||
"DOM" | ||
], | ||
"esModuleInterop": true, | ||
"allowJs": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": [ | ||
"./*" | ||
], | ||
"@/*": [ | ||
"./*" | ||
] | ||
}, | ||
"types": [ | ||
"@nuxt/types" | ||
] | ||
} | ||
} |