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
<script setup lang="ts"> | |
import BootstrapIcons from "bootstrap-icons/bootstrap-icons.svg"; | |
import { computed, PropType } from "vue"; | |
const props = defineProps({ | |
icon: { | |
type: String, | |
required: true, | |
}, | |
size: { |
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
<script> | |
import { useFellowship } from '@/stores/fellowship' | |
export default { | |
setup() { | |
const fellowship = useFellowship() | |
// Access to the state | |
// can be done directly | |
console.log(fellowship.heroes) |
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
import { defineStore } from 'pinia' | |
export const useFellowship = defineStore('fellowship', { | |
state: () => { | |
return { heroes: ['Aragorn', 'Legolas', 'Gimli', 'Gandalf'] } | |
}, | |
actions: { | |
addHero(hero) { | |
this.heroes.push(hero) | |
}, |
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
import { reactive } from "vue"; | |
export const store = { | |
state: reactive({ | |
heroes: ['Aragorn', 'Legolas', 'Gimli', 'Gandalf'] | |
}), | |
addHero(hero) { | |
this.state.heroes.push(hero); | |
} | |
}; |
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
<router> | |
{ | |
path: '/post/:id/:title?' | |
} | |
</router> |
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
<router> | |
{ | |
path: '/posts', | |
alias: [ | |
'/articles', | |
'/blog' | |
] | |
} | |
</router> |
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
<router> | |
{ | |
path: '/posts' | |
} | |
</router> |
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
<template> | |
<div> | |
<p v-if="$fetchState.pending">Loading....</p> | |
<p v-else-if="$fetchState.error">Error while fetching mountains</p> | |
<ul v-else> | |
<li v-for="(mountain, index) in mountains" :key="index"> | |
{{ mountain.title }} | |
</li> | |
</ul> | |
</div> |
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
<template> | |
<div> | |
<div v-if="$nuxt.isOffline">You are offline</div> | |
<nuxt /> | |
</div> | |
</template> |
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
<template> | |
<div> | |
<div>{{ content }}</div> | |
<button @click="refresh">Refresh</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
asyncData() { |
NewerOlder