当前位置:网站首页>Pinia module division
Pinia module division
2022-07-06 23:52:00 【Liang Yunliang】
pinia The module division of is through js Divided by naming .
Example :
First step : Split store file
- store/index.ts
import {
createPinia } from "pinia"
const store = createPinia()
export default store
- store/user.ts
import {
defineStore} from "pinia"
export const useUserStore = defineStore({
//js name
id: "user",
state: () => {
return {
name: ' Zhang San ',
age: 18
}
}
})
- store/order.ts
import {
defineStore} from "pinia"
export const useOrderStore = defineStore({
//js name
id: "order",
state: () => {
return {
orderList: [{
id: 1001, total: 6666}, {
id: 1002, total: 8888}, {
id: 1003, total: 9999}]
}
}
})
The second step :vue
- User.vue
<template>
User:{
{ name }} == {
{ age }}
</template>
<script setup lang="ts"> import {
storeToRefs} from "pinia" import {
useUserStore} from "@/store/module/user" const userStore = useUserStore() const {
name, age} = storeToRefs(userStore) </script>
- Order.vue
<template>
order <br>
{
{order}}
</template>
<script setup lang='ts'> import {
storeToRefs} from "pinia" import {
useOrderStore} from "@/store/module/order" const orderStore = useOrderStore() const order = storeToRefs(orderStore) </script>
边栏推荐
- The tutorial of computer reinstallation win10 system is simple and easy to understand. It can be reinstalled directly without U disk
- 【系统分析师之路】第七章 复盘系统设计(面向服务开发方法)
- How much does the mlperf list weigh when AI is named?
- 零代码高回报,如何用40套模板,能满足工作中95%的报表需求
- 【通信】两层无线 Femtocell 网络上行链路中的最优功率分配附matlab代码
- MATLIB从excel表中读取数据并画出函数图像
- 本地部署 zeppelin 0.10.1
- Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
- 为什么完全背包要用顺序遍历?简要解释一下
- 每日刷题记录 (十五)
猜你喜欢

pytest多进程/多线程执行测试用例

11 preparations for Web3 and Decentralization for traditional enterprises

Hydrogen future industry accelerates | the registration channel of 2022 hydrogen energy specialty special new entrepreneurship competition is opened!

MVC and MVVM

Yaduo Sangu IPO

DevOps可以帮助减少技术债务的十种方式

STM32 enters and wakes up the stop mode through the serial port

Who said that new consumer brands collapsed? Someone behind me won

After 3 years of testing bytecan software, I was ruthlessly dismissed in February, trying to wake up my brother who was paddling

The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
随机推荐
pytest多进程/多线程执行测试用例
在docker中快速使用各个版本的PostgreSQL数据库
The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
求帮助xampp做sqlilab是一片黑
Example code of MySQL split string as query condition
leetcode:236. The nearest common ancestor of binary tree
The worse the AI performance, the higher the bonus? Doctor of New York University offered a reward for the task of making the big model perform poorly
pinia 模块划分
Experiment 5: common automation libraries
Oracle对表进行的常用修改命令
Résumé des connaissances de gradle
DAY FIVE
DAY TWO
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
Server SMP, NUMA, MPP system learning notes.
Local deployment Zeppelin 0.10.1
Please help xampp to do sqlilab is a black
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
英国都在试行4天工作制了,为什么BAT还对996上瘾?
Matplotlib draws a histogram and adds values to the graph