Pinia nanny-level tutorial Vite + Vue project creation

 

Pinia Nanny Level Tutorial

Vue3 has been launched for a long time, and the ecology around it is getting more and more perfect. When we used Vue2 before, Vuex can be said to be a must. As a state management tool, it has brought us great convenience. After the launch of Vue3, although many things have changed compared to Vue2, the core things have not changed, such as state management, routing and so on. There are three types of Vue, You Dashen recommended that we use pinia to achieve state management, and he also said that pinia is a new version of Vuex.

So what is the sacred pinia, this article will take everyone to learn about it!

1. What is pinia?

If you have learned Vue2, then you must have used Vuex. We all know that Vuex mainly plays the role of state management in Vue2. The so-called state management is simply a place to store data. The data stored in Vuex can be accessed by various components. It is an important part of the Vue ecology. component.

Since Vuex is so important, how can it be discarded in Vue3!

In Vue3, you can use the traditional Vuex to achieve state management, or you can use the latest pinia to achieve state management. Let's take a look at how the official website explains pinia.

The official website explains:

Pinia is a repository for Vue that allows you to share state across components/pages.

From the explanation on the above official website, it is not difficult to see that pinia and Vuex have the same function, and it also acts as a data storage function. The data stored in pinia allows

Guess you like

Origin blog.csdn.net/qq_44848480/article/details/129519546