--- /dev/null
+<template>
+ <div class="vueschool">
+ <a
+ :href="`${href}?friend=vuerouter`"
+ target="_blank"
+ rel="sponsored noopener"
+ :title="title"
+ >
+ <slot>Watch a free video lesson on Vue School</slot>
+ </a>
+ </div>
+</template>
+<script>
+export default {
+ props: {
+ href: { type: String, required: true },
+ title: { type: String, required: true },
+ },
+}
+</script>
+<style scoped>
+.vueschool {
+ margin-top: 20px;
+ background-color: var(--code-bg-color);
+ padding: 1em 1.25em;
+ border-radius: 2px;
+ position: relative;
+ display: flex;
+}
+.vueschool a {
+ color: var(--c-text);
+ position: relative;
+ padding-left: 36px;
+}
+.vueschool a:before {
+ content: '';
+ position: absolute;
+ display: block;
+ width: 30px;
+ height: 30px;
+ top: calc(50% - 15px);
+ left: -4px;
+ border-radius: 50%;
+ background-color: #73abfe;
+}
+.vueschool a:after {
+ content: '';
+ position: absolute;
+ display: block;
+ width: 0;
+ height: 0;
+ top: calc(50% - 5px);
+ left: 8px;
+ border-top: 5px solid transparent;
+ border-bottom: 5px solid transparent;
+ border-left: 8px solid #fff;
+}
+</style>
\ No newline at end of file
import Theme from 'vitepress/theme'
+import VueSchoolLink from '../components/VueSchoolLink.vue'
import { Layout } from './Layout'
import './custom.css'
import './code-theme.css'
Layout,
- // enhanceApp({ app }) {
- // app.use(createPinia())
- // },
+ enhanceApp({ app }) {
+ app.component('VueSchoolLink', VueSchoolLink)
+ },
}
export default config
# Actions
+<VueSchoolLink href="https://vueschool.io/lessons/synchronous-and-asynchronous-actions-in-pinia"/>
+
Actions are the equivalent of [methods](https://v3.vuejs.org/guide/data-methods.html#methods) in components. They can be defined with the `actions` property in `defineStore()` and **they are perfect to define business logic**:
```js
# Getters
+<VueSchoolLink href="https://vueschool.io/lessons/getters-in-pinia"/>
+
Getters are exactly the equivalent of [computed values](https://v3.vuejs.org/guide/reactivity-computed-watchers.html#computed-values) for the state of a Store. They can be defined with the `getters` property in `defineStore()`. They receive the `state` as the first parameter **to encourage** the usage of arrow function:
```js
# Defining a Store
+<VueSchoolLink href="https://vueschool.io/lessons/define-your-first-pinia-store"/>
+
Before diving into core concepts, we need to know that a store is defined using `defineStore()` and that it requires a **unique** name, passed as the first argument:
```js
# State
+<VueSchoolLink href="https://vueschool.io/lessons/access-state-from-a-pinia-store"/>
+
The state is, most of the time, the central part of your store. People often start by defining the state that represents their app. In Pinia the state is defined as a function that returns the initial state. This allows Pinia to work in both Server and Client Side.
```js
# Introduction
+<VueSchoolLink href="https://vueschool.io/lessons/introduction-to-pinia"/>
+
Pinia [started](https://github.com/vuejs/pinia/commit/06aeef54e2cad66696063c62829dac74e15fd19e) as an experiment to redesign what a Store for Vue could look like with the [Composition API](https://github.com/vuejs/composition-api) around November 2019. Since then, the initial principles are still the same, but Pinia works for both Vue 2 and Vue 3 **and doesn't require you to use the composition API**. The API is the same for both except for _installation_ and _SSR_, and these docs are targeted to Vue 3 **with notes about Vue 2** whenever necessary so it can be read by Vue 2 and Vue 3 users!
## Why should I use Pinia?