Skip to content

Instantly share code, notes, and snippets.

View fadamakis's full-sized avatar
👋
Hello, World!

Fotis Adamakis fadamakis

👋
Hello, World!
View GitHub Profile
<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: {
<script>
import { useFellowship } from '@/stores/fellowship'
export default {
setup() {
const fellowship = useFellowship()
// Access to the state
// can be done directly
console.log(fellowship.heroes)
import { defineStore } from 'pinia'
export const useFellowship = defineStore('fellowship', {
state: () => {
return { heroes: ['Aragorn', 'Legolas', 'Gimli', 'Gandalf'] }
},
actions: {
addHero(hero) {
this.heroes.push(hero)
},
@fadamakis
fadamakis / store.js
Created June 6, 2022 18:05
Reactive API
import { reactive } from "vue";
export const store = {
state: reactive({
heroes: ['Aragorn', 'Legolas', 'Gimli', 'Gandalf']
}),
addHero(hero) {
this.state.heroes.push(hero);
}
};
<router>
{
path: '/post/:id/:title?'
}
</router>
<router>
{
path: '/posts',
alias: [
'/articles',
'/blog'
]
}
</router>
<router>
{
path: '/posts'
}
</router>
<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>
<template>
<div>
<div v-if="$nuxt.isOffline">You are offline</div>
<nuxt />
</div>
</template>
<template>
<div>
<div>{{ content }}</div>
<button @click="refresh">Refresh</button>
</div>
</template>
<script>
export default {
asyncData() {