18 | {{ jokes.current.setup }} 19 |25 |
20 |
21 |22 | {{ jokes.current.punchline }} 23 |
24 |
A simple about page that does not use any store.
5 | 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /packages/online-playground/src/download/template/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | 4 | createApp(App).mount('#app') 5 | -------------------------------------------------------------------------------- /packages/nuxt/playground/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "main": "fake-main.js", 5 | "name": "pinia-nuxt-playground" 6 | } 7 | -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_large.png -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_medium.png -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_small.png -------------------------------------------------------------------------------- /packages/online-playground/src/vue-server-renderer-dev-proxy.ts: -------------------------------------------------------------------------------- 1 | // serve vue/server-renderer to the iframe sandbox during dev. 2 | export * from 'vue/server-renderer' 3 | -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_large_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_large_2x.png -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_small_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_small_2x.png -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_smallest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_smallest.png -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_medium_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_medium_2x.png -------------------------------------------------------------------------------- /packages/docs/public/vuejsde-conf/vuejsdeconf_banner_smallest_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs/pinia/HEAD/packages/docs/public/vuejsde-conf/vuejsdeconf_banner_smallest_2x.png -------------------------------------------------------------------------------- /packages/nuxt/playground/layers/layer-domain/stores/basic.ts: -------------------------------------------------------------------------------- 1 | export const useBasicStore = defineStore('layer-basic', () => { 2 | const count = ref(0) 3 | 4 | return { count } 5 | }) 6 | -------------------------------------------------------------------------------- /packages/pinia/__tests__/vitest-setup.ts: -------------------------------------------------------------------------------- 1 | import { beforeEach } from 'vitest' 2 | import { setActivePinia } from '../src' 3 | 4 | beforeEach(() => { 5 | setActivePinia(undefined) 6 | }) 7 | -------------------------------------------------------------------------------- /packages/size-check/src/pinia.js: -------------------------------------------------------------------------------- 1 | import { createPinia, defineStore } from 'pinia' 2 | 3 | export const pinia = createPinia() 4 | // @ts-ignore 5 | export const useStore = defineStore() 6 | -------------------------------------------------------------------------------- /packages/testing/src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module @pinia/testing 3 | */ 4 | export { createTestingPinia } from './testing' 5 | export type { TestingPinia, TestingOptions } from './testing' 6 | -------------------------------------------------------------------------------- /packages/nuxt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./playground/.nuxt/tsconfig.json", 3 | "include": [ 4 | "./shims.d.ts", 5 | // missing in the playground 6 | "./src" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/nuxt/playground/domain/one/stores/testStore.ts: -------------------------------------------------------------------------------- 1 | export const useTestStore = defineStore('test', () => { 2 | // console.log('I was defined within a store directory') 3 | return {} 4 | }) 5 | -------------------------------------------------------------------------------- /packages/online-playground/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import { DefineComponent } from 'vue' 3 | const component: DefineComponent<{}, {}, any> 4 | export default component 5 | } 6 | -------------------------------------------------------------------------------- /packages/playground/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import { DefineComponent } from 'vue' 3 | const component: DefineComponent<{}, {}, any> 4 | export default component 5 | } 6 | -------------------------------------------------------------------------------- /packages/nuxt/src/runtime/composables.ts: -------------------------------------------------------------------------------- 1 | import { useNuxtApp } from '#app' 2 | import type { Pinia } from 'pinia' 3 | export * from 'pinia' 4 | 5 | export const usePinia = () => useNuxtApp().$pinia as Pinia 6 | -------------------------------------------------------------------------------- /packages/nuxt/playground/stores/nested/some-store.ts: -------------------------------------------------------------------------------- 1 | export const useSomeStoreStore = defineStore('some-store', () => { 2 | // console.log('I was defined within a nested store directory') 3 | return {} 4 | }) 5 | -------------------------------------------------------------------------------- /packages/pinia/index.cjs: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (process.env.NODE_ENV === 'production') { 4 | module.exports = require('./dist/pinia.prod.cjs') 5 | } else { 6 | module.exports = require('./dist/pinia.cjs') 7 | } 8 | -------------------------------------------------------------------------------- /packages/docs/zh/api/index.md: -------------------------------------------------------------------------------- 1 | API 文档 2 | 3 | # API 文档 %{#api-documentation}% 4 | 5 | ## 模块 %{#modules}% 6 | 7 | - [@pinia/nuxt](modules/pinia_nuxt.md) 8 | - [@pinia/testing](modules/pinia_testing.md) 9 | - [pinia](modules/pinia.md) 10 | -------------------------------------------------------------------------------- /packages/online-playground/src/download/template/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /packages/pinia/test-dts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "declaration": true, 6 | "noImplicitReturns": false 7 | }, 8 | "include": ["./"], 9 | "exclude": ["../__tests__", "../src"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/online-playground/deploy-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # check for netlify to skip deploy 4 | # needed because we cannot use && in netlify.toml 5 | 6 | # exit 0 will skip the build while exit 1 will build 7 | 8 | git diff --quiet 'HEAD^' HEAD . && git diff --quiet 'HEAD^' HEAD ../pinia 9 | -------------------------------------------------------------------------------- /packages/online-playground/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | import '@vue/repl/style.css' 4 | 5 | // @ts-expect-error Custom window property 6 | window.VUE_DEVTOOLS_CONFIG = { 7 | defaultSelectedAppId: 'repl', 8 | } 9 | 10 | createApp(App).mount('#app') 11 | -------------------------------------------------------------------------------- /packages/testing/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "files": ["./src/**/*.ts"], 4 | "exclude": ["./src/**/*.spec.ts"], 5 | "compilerOptions": { 6 | "rootDir": "../..", 7 | "target": "esnext", 8 | "module": "esnext", 9 | "strict": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/online-playground/src/download/template/README.md: -------------------------------------------------------------------------------- 1 | # Vite Vue Starter 2 | 3 | This is a project template using [Vite](https://vitejs.dev/). It requires [Node.js](https://nodejs.org) v12+. 4 | 5 | To start: 6 | 7 | ```sh 8 | npm install 9 | npm run dev 10 | 11 | # if using yarn: 12 | yarn 13 | yarn dev 14 | ``` 15 | -------------------------------------------------------------------------------- /packages/testing/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | clean: true, 6 | format: ['cjs', 'esm'], 7 | dts: true, 8 | external: ['vue', 'pinia'], 9 | tsconfig: './tsconfig.build.json', 10 | // onSuccess: 'npm run build:fix', 11 | }) 12 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[javascript]": { 3 | "editor.formatOnSave": true 4 | }, 5 | "[typescript]": { 6 | "editor.formatOnSave": true 7 | }, 8 | "typescript.tsdk": "node_modules/typescript/lib", 9 | "jest.jestCommandLine": "yarn jest --watchAll", 10 | "editor.defaultFormatter": "esbenp.prettier-vscode" 11 | } 12 | -------------------------------------------------------------------------------- /packages/nuxt/playground/stores/with-skip-hydrate.ts: -------------------------------------------------------------------------------- 1 | import { skipHydrate } from 'pinia' 2 | 3 | export const useWithSkipHydrateStore = defineStore('with-skip-hydrate', () => { 4 | const skipped = skipHydrate( 5 | ref({ 6 | text: 'I should not be serialized or hydrated', 7 | }) 8 | ) 9 | return { skipped } 10 | }) 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | npm-debug.log 4 | yarn-error.log 5 | .nyc_output 6 | coverage.lcov 7 | dist 8 | .DS_Store 9 | temp 10 | test-dts/tsconfig.tsbuildinfo 11 | .env 12 | packages/*/LICENSE 13 | explorations 14 | docs-api 15 | packages/docs/api 16 | .yalc 17 | yalc.lock 18 | .idea 19 | .vitepress/cache 20 | tsconfig.vitest-temp.json 21 | -------------------------------------------------------------------------------- /packages/online-playground/README.md: -------------------------------------------------------------------------------- 1 | # SFC Playground 2 | 3 | This is continuously deployed at [https://play.vuejs.org](https://play.vuejs.org). 4 | 5 | ## Run Locally in Dev 6 | 7 | In repo root: 8 | 9 | ```sh 10 | pnpm dev-sfc 11 | ``` 12 | 13 | ## Build for Prod 14 | 15 | In repo root 16 | 17 | ```sh 18 | pnpm build-sfc-playground 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/pinia/src/global.d.ts: -------------------------------------------------------------------------------- 1 | // Global compile-time constants 2 | declare var __DEV__: boolean 3 | declare var __TEST__: boolean 4 | declare var __FEATURE_PROD_DEVTOOLS__: boolean 5 | declare var __BROWSER__: boolean 6 | declare var __USE_DEVTOOLS__: boolean 7 | declare var __CI__: boolean 8 | declare var __VUE_DEVTOOLS_TOAST__: ( 9 | message: string, 10 | type?: 'normal' | 'error' | 'warn' 11 | ) => void 12 | -------------------------------------------------------------------------------- /packages/playground/src/api/jokes.ts: -------------------------------------------------------------------------------- 1 | import { mande } from 'mande' 2 | 3 | export const jokes = mande('https://official-joke-api.appspot.com', { 4 | headers: { 5 | 'Content-Type': null, 6 | }, 7 | }) 8 | 9 | export interface Joke { 10 | id: number 11 | type: string 12 | setup: string 13 | punchline: string 14 | } 15 | 16 | export function getRandomJoke() { 17 | return jokes.get{{ skipHydrateState }}
13 | 14 | -------------------------------------------------------------------------------- /packages/playground/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | ///Counter :{{ counter.n }}. Double: {{ counter.double }}
5 | 6 | 7 | 8 |
11 | counter.$state:
12 |
{{ counter.$state }}
15 |
16 |
17 |
22 |
--------------------------------------------------------------------------------
/packages/playground/src/views/404.vue:
--------------------------------------------------------------------------------
1 |
2 | Select one of the pages ⤵️
3 | 4 |
2 |
3 |
4 |
5 |
3 | I have a store "{{ userStore.name }}". I have 4 | {{ cartStore.items.length }} items in the cart. 5 |
6 |Counter: {{ counterStore.double }} = 2 x {{ counterStore.n }}
8 | 9 | 10 | 11 |Count: {{ counter.count }} x 2 = {{ counter.double }}
20 | 21 |{{ counter.$state }}
22 |
23 | Layer store: {{ layerStore.count }}
26 |3 | I have a store "{{ userStore.name }}". I have 4 | {{ cartStore.items.length }} items in the cart. 5 |
6 |Counter: {{ counterStore.double }} = 2 x {{ counterStore.n }}
8 | 9 | 10 | 11 |Counter :{{ counter.n }}. Double: {{ counter.double }}
9 | 10 |
11 | Increment the Store
12 |
13 |
14 |
15 |
16 |
17 |
27 |
30 | Other actions
31 |
32 |
35 |
36 |
37 |
38 |
41 |
42 |
counter.$state:
{{ counter.$state }}
49 |
50 |
51 |
59 |
--------------------------------------------------------------------------------
/packages/nuxt/README.md:
--------------------------------------------------------------------------------
1 | # `@pinia/nuxt`
2 |
3 | > Nuxt module for Pinia
4 |
5 | ## Automatic Installation
6 |
7 | Use `nuxi` to automatically add this module to your Nuxt project:
8 |
9 | ```shell
10 | npx nuxi@latest module add pinia
11 | ```
12 |
13 | ## Manual Installation
14 |
15 | Add dependencies to your Nuxt project:
16 |
17 | ```shell
18 | npm i pinia @pinia/nuxt
19 | ```
20 |
21 | Enable the `@pinia/nuxt` module in `nuxt.config.ts`:
22 |
23 | ```js
24 | export default defineNuxtConfig({
25 | modules: ['@pinia/nuxt'],
26 | })
27 | ```
28 |
29 | ## Configuring the Module
30 |
31 | By default, this module adds `stores` folder to auto imports, in which you can organize code related to Pinia stores in one place.
32 | > [!TIP]
33 | > In the new directory structure introduced since Nuxt 4, this directory is `app/stores`.
34 |
35 | You can customize this behaviour using the `pinia` property in `nuxt.config.ts`:
36 |
37 | ```js
38 | export default defineNuxtConfig({
39 | modules: ['@pinia/nuxt'],
40 | // configure the module using `pinia` property
41 | pinia: {
42 | /**
43 | * Automatically add stores dirs to the auto imports. This is the same as
44 | * directly adding the dirs to the `imports.dirs` option. If you want to
45 | * also import nested stores, you can use the glob pattern `./stores/**`
46 | * (on Nuxt 3) or `app/stores/**` (on Nuxt 4+)
47 | *
48 | * @default `['stores']`
49 | */
50 | storesDirs: []
51 | }
52 | })
53 | ```
54 |
55 | ## License
56 |
57 | [MIT](http://opensource.org/licenses/MIT)
58 |
--------------------------------------------------------------------------------
/packages/playground/src/stores/nasa.ts:
--------------------------------------------------------------------------------
1 | import useSWRV from 'swrv'
2 | import { ref } from 'vue'
3 | import { acceptHMRUpdate, defineStore } from 'pinia'
4 | import { getNASAPOD } from '../api/nasa'
5 |
6 | export const useNasaStore = defineStore('nasa-pod-swrv', ({ action }) => {
7 | // can't go past today
8 | const today = new Date().toISOString().slice(0, 10)
9 |
10 | // const currentDate = computedCounter :{{ counter.n }}. Double: {{ counter.double }}
27 | 28 |
29 | Increment the Store
30 |
31 |
32 |
33 |
34 |
35 |
45 |
48 | Other actions
49 |
50 |
51 |
52 |
53 |
counter.$state:
{{ counter.$state }}
60 |
61 |
--------------------------------------------------------------------------------
/packages/docs/zh/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar: 'auto'
3 | editLinks: false
4 | sidebarDepth: 3
5 | ---
6 |
7 | [API 文档](../index.md) / [pinia](../modules/pinia.md) / SubscriptionCallbackMutationPatchObject
8 |
9 | # 接口:SubscriptionCallbackMutationPatchObject${hash}。',
19 | }
20 |
21 | const theme: Theme = {
22 | ...DefaultTheme,
23 | Layout() {
24 | return h(DefaultTheme.Layout, null, {
25 | 'home-hero-image': () => h('div', { class: 'image-src' }, h(PiniaLogo)),
26 | // 'home-features-after': () => h(HomeSponsors),
27 | 'aside-ads-before': () => h(AsideSponsors),
28 | // 'layout-top': () => h(VuejsdeConfBanner),
29 | 'doc-before': () => h(TranslationStatus, { status, i18nLabels }),
30 | })
31 | },
32 |
33 | enhanceApp({ app }) {
34 | app.component('VueSchoolLink', VueSchoolLink)
35 | app.component('VueMasteryLogoLink', VueMasteryLogoLink)
36 | app.component('MasteringPiniaLink', MasteringPiniaLink)
37 | app.component('RuleKitLink', RuleKitLink)
38 | },
39 | }
40 |
41 | export default theme
42 |
--------------------------------------------------------------------------------
/packages/pinia/__tests__/combinedStores.spec.ts:
--------------------------------------------------------------------------------
1 | import { beforeEach, describe, it, expect } from 'vitest'
2 | import { computed, ref } from 'vue'
3 | import { createPinia, defineStore, setActivePinia } from '../src'
4 |
5 | describe('Composing stores', () => {
6 | beforeEach(() => {
7 | setActivePinia(createPinia())
8 | })
9 |
10 | function useCounter() {
11 | const n = ref(0)
12 | const double = computed(() => n.value)
13 |
14 | function increment(amount = 1) {
15 | n.value += amount
16 | }
17 |
18 | return { n, double, increment }
19 | }
20 |
21 | const useStoreA = defineStore('a', () => {
22 | const { n, double, increment } = useCounter()
23 | const b = useStoreB()
24 |
25 | function changeB() {
26 | b.n++
27 | }
28 |
29 | function getInnerB() {
30 | return b
31 | }
32 |
33 | return { n, increment, double, changeB, getInnerB }
34 | })
35 |
36 | const useStoreB = defineStore('b', () => {
37 | const { n, double, increment } = useCounter()
38 | const a = useStoreA()
39 |
40 | function changeA() {
41 | a.n++
42 | }
43 |
44 | function getInnerA() {
45 | return a
46 | }
47 |
48 | return { n, increment, double, changeA, getInnerA }
49 | })
50 |
51 | it('works', () => {
52 | expect(() => {
53 | useStoreA()
54 | useStoreB()
55 | }).not.toThrow()
56 | })
57 |
58 | it('they can use each other', () => {
59 | const b = useStoreB()
60 | const a = useStoreA()
61 |
62 | expect(a).toBe(b.getInnerA())
63 | expect(b).toBe(a.getInnerB())
64 |
65 | expect(a.n).toBe(0)
66 | b.changeA()
67 | expect(a.n).toBe(1)
68 |
69 | expect(b.n).toBe(0)
70 | a.changeB()
71 | expect(b.n).toBe(1)
72 | })
73 | })
74 |
--------------------------------------------------------------------------------
/packages/docs/zh/cookbook/vscode-snippets.md:
--------------------------------------------------------------------------------
1 | # VS Code 代码片段
2 |
3 | 8 | 9 |
10 | 16 |
20 | ❌ Error:
21 |
22 | {{ error }}
23 |
18 | {{ jokes.current.setup }} 19 |25 |
20 |
21 |22 | {{ jokes.current.punchline }} 23 |
24 |
{{ jokes.$state }}
30 |
31 |
32 |
66 |
67 |
83 |
--------------------------------------------------------------------------------
/packages/docs/zh/core-concepts/outside-component-usage.md:
--------------------------------------------------------------------------------
1 | # 在组件外使用 store %{#using-a-store-outside-of-a-component}%
2 |
3 |
18 |
19 |
20 | Get the Pinia Cheat Sheet from Vue Mastery
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/packages/pinia/__tests__/pinia/stores/cart.ts:
--------------------------------------------------------------------------------
1 | import { defineStore } from '../../../src'
2 | import { useUserStore } from './user'
3 |
4 | export const useCartStore = defineStore('cart', {
5 | state: () => ({
6 | id: 2,
7 | rawItems: [] as string[],
8 | }),
9 | getters: {
10 | items: (state) =>
11 | state.rawItems.reduce(
12 | (items, item) => {
13 | const existingItem = items.find((it) => it.name === item)
14 |
15 | if (!existingItem) {
16 | items.push({ name: item, amount: 1 })
17 | } else {
18 | existingItem.amount++
19 | }
20 |
21 | return items
22 | },
23 | [] as { name: string; amount: number }[]
24 | ),
25 | },
26 |
27 | actions: {
28 | addItem(name: string) {
29 | this.rawItems.push(name)
30 | },
31 |
32 | removeItem(name: string) {
33 | const i = this.rawItems.indexOf(name)
34 | if (i > -1) this.$state.rawItems.splice(i, 1)
35 | },
36 |
37 | // TODO: use multiple stores
38 | // https://github.com/vuejs/vue-next-internal-discussions/issues/22
39 | async purchaseItems() {
40 | const user = useUserStore()
41 | if (!user.name) return
42 |
43 | // console.log('Purchasing', this.items)
44 | const n = this.items.length
45 | this.rawItems = []
46 |
47 | return { amount: n, user: user.name }
48 | },
49 | },
50 | })
51 |
52 | export type CartStore = ReturnType8 | 9 |
10 | 16 |16 | {{ jokes.current.setup }} 17 |23 |
18 |
19 |20 | {{ jokes.current.punchline }} 21 |
22 |
{{ jokes.$state }}
28 |
29 |
30 |
71 |
72 |
88 |
--------------------------------------------------------------------------------
/packages/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: home
3 |
4 | title: Pinia
5 | titleTemplate: The intuitive store for Vue.js
6 |
7 | hero:
8 | name: Pinia
9 | text: The intuitive store for Vue.js
10 | tagline: Type Safe, Extensible, and Modular by design. Forget you are even using a store.
11 | image:
12 | src: /logo.svg
13 | alt: Pinia
14 | actions:
15 | - theme: brand
16 | text: Get Started
17 | link: /introduction
18 | - theme: alt
19 | text: Demo
20 | link: https://stackblitz.com/github/piniajs/example-vue-3-vite
21 | - theme: cta rulekit
22 | text: RuleKit
23 | link: https://rulekit.dev?from=pinia
24 | - theme: cta mastering-pinia
25 | text: ' '
26 | link: https://masteringpinia.com
27 | - theme: cta vueschool
28 | text: Watch Video Introduction
29 | link: https://vueschool.io/lessons/introduction-to-pinia?friend=vuerouter&utm_source=pinia&utm_medium=link&utm_campaign=homepage
30 | - theme: cta vue-mastery
31 | text: Get the Pinia Cheat Sheet
32 | link: https://www.vuemastery.com/pinia?coupon=PINIA-DOCS&via=eduardo
33 |
34 | features:
35 | - title: 💡 Intuitive
36 | details: Stores are as familiar as components. API designed to let you write well organized stores.
37 | - title: 🔑 Type Safe
38 | details: Types are inferred, which means stores provide you with autocompletion even in JavaScript!
39 | - title: ⚙️ Devtools support
40 | details: Pinia hooks into Vue devtools to give you an enhanced development experience.
41 | - title: 🔌 Extensible
42 | details: React to store changes and actions to extend Pinia with transactions, local storage synchronization, etc.
43 | - title: 🏗 Modular by design
44 | details: Build multiple stores and let your bundler code split them automatically.
45 | - title: 📦 Extremely light
46 | details: Pinia weighs ~1.5kb, you will forget it's even there!
47 | ---
48 |
49 |
53 |
54 |
5 |
17 |
27 |
28 |
23 | {{ jokes.data.setup }} 24 |30 | 31 | 32 | 33 |
25 |
26 |27 | {{ jokes.data.punchline }} 28 |
29 |
Error: {{ jokes.error.message }}
34 | 35 |{{ jokes.$state }}
40 |
41 |
42 |
78 |
79 |
95 |
--------------------------------------------------------------------------------
/packages/docs/zh/cookbook/options-api.md:
--------------------------------------------------------------------------------
1 | # 不使用 `setup()` 的用法 %{#usage-without-setup}%
2 |
3 |