Vue.js / Nuxt.js

Pinia State Management

Pinia stores, state, actions, getters, composition API integration, store composition, setup stores

20 面接問題·
Junior
1

What is a Pinia store?

回答

A Pinia store is a centralized reactive object that contains state, getters, and actions to manage application state. Unlike Vuex, Pinia simplifies the syntax by eliminating mutations and offers native TypeScript support. Pinia stores enable sharing data and business logic between multiple components in an organized and maintainable way.

2

Which function should be used to create a Pinia store?

回答

The defineStore function is the standard method for creating a Pinia store. It accepts a unique identifier as the first parameter and either an options object (option store) or a setup function (setup store) as the second parameter. This function returns a composable that can be used in components to access the store.

3

In a Pinia store, how to define state data?

回答

In a Pinia option store, state is defined as a function that returns an object containing reactive data. This functional approach ensures that each store instance gets its own isolated state. The state automatically becomes reactive thanks to Vue's reactivity system, allowing components to react to data changes.

4

What are actions in a Pinia store?

5

What are getters in a Pinia store?

+17 面接問題

次の面接に向けてVue.js / Nuxt.jsをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める