当前位置:网站首页>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>
边栏推荐
- Newsletter L Huobi ventures is in-depth contact with genesis public chain
- Master binary tree in one article
- How about the order management of okcc call center
- Design a red envelope grabbing system
- 基础图表解读“东方甄选”爆火出圈数据
- Gradle知识概括
- 达晨史上最大单笔投资,今天IPO了
- MySQL implementation of field segmentation from one line to multiple lines of example code
- MATLIB从excel表中读取数据并画出函数图像
- 2022 latest blind box mall complete open source operation source code / docking visa free payment interface / building tutorial
猜你喜欢

【无人机】多无人协同任务分配程序平台含Matlab代码

【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤

What should I do if the USB flash disk data is formatted and how can I recover the formatted USB flash disk data?

11 preparations for Web3 and Decentralization for traditional enterprises

Rider离线使用Nuget包的方法

【通信】两层无线 Femtocell 网络上行链路中的最优功率分配附matlab代码

How to find out if the U disk file of the computer reinstallation system is hidden

Knowledge * review

How much does the mlperf list weigh when AI is named?
![[communication] optimal power allocation in the uplink of two-layer wireless femtocell network with matlab code](/img/47/741b89d94a2b0003937f32bdedfa19.png)
[communication] optimal power allocation in the uplink of two-layer wireless femtocell network with matlab code
随机推荐
The method of reinstalling win10 system is as simple as that
(leetcode) sum of two numbers
okcc呼叫中心的订单管理时怎么样的
How about the order management of okcc call center
《数字经济全景白皮书》保险数字化篇 重磅发布
MySQL implementation of field segmentation from one line to multiple lines of example code
DAY SIX
Laravel8 uses passport authentication to log in and generate a token
公链与私链在数据隐私和吞吐量上的竞争
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
PDF文档签名指南
Zero code and high return. How to use 40 sets of templates to meet 95% of the reporting needs in the work
17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
Wasserstein Slim GAIN with Gradient Penalty(WSGAIN-GP)介绍及代码实现——基于生成对抗网络的缺失数据填补
Close unregistering application XXX with Eureka with status down after Eureka client starts
How much does the mlperf list weigh when AI is named?
士大夫哈哈哈
PostgreSQL使用Pgpool-II实现读写分离+负载均衡
自动化测试工具Katalon(Web)测试操作说明