当前位置:网站首页>pinia 模块划分
pinia 模块划分
2022-07-06 16:25:00 【梁云亮】
pinia的模块划分是通过js命名来划分的。
示例:
第一步:拆分store文件
- 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命名
id: "user",
state: () => {
return {
name: '张三',
age: 18
}
}
})
- store/order.ts
import {
defineStore} from "pinia"
export const useOrderStore = defineStore({
//js命名
id: "order",
state: () => {
return {
orderList: [{
id: 1001, total: 6666}, {
id: 1002, total: 8888}, {
id: 1003, total: 9999}]
}
}
})
第二步: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>
边栏推荐
- 服务器SMP、NUMA、MPP体系学习笔记。
- Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
- The important data in the computer was accidentally deleted by mistake, which can be quickly retrieved by this method
- 内网穿透zerotier 外网(手机、电脑等)访问内网设备(树莓派、NAS、电脑等)
- 零代码高回报,如何用40套模板,能满足工作中95%的报表需求
- Cas d'essai fonctionnel universel de l'application
- Restoration analysis of protobuf protocol of bullet screen in station B
- MATLIB reads data from excel table and draws function image
- Realize colorful lines and shape your heart
- The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
猜你喜欢
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
(1) Chang'an chain learning notes - start Chang'an chain
After 3 years of testing bytecan software, I was ruthlessly dismissed in February, trying to wake up my brother who was paddling
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
电脑重装系统u盘文件被隐藏要怎么找出来
B 站弹幕 protobuf 协议还原分析
Can online reload system software be used safely? Test use experience to share with you
Cas d'essai fonctionnel universel de l'application
Rider离线使用Nuget包的方法
Gold three silver four, don't change jobs
随机推荐
The important data in the computer was accidentally deleted by mistake, which can be quickly retrieved by this method
请问async i/o可以由udf算子实现然后用sql api调用吗?目前好像只看到Datastre
Let me ask you if there are any documents or cases of flynk SQL generation jobs. I know that flynk cli can create tables and specify items
Automatic test tool katalon (WEB) test operation instructions
【212】php发送post请求有哪三种方法
本地部署 zeppelin 0.10.1
零代码高回报,如何用40套模板,能满足工作中95%的报表需求
The programmer refused the offer because of low salary, HR became angry and netizens exploded
短链的设计
Restoration analysis of protobuf protocol of bullet screen in station B
How to answer the dualistic opposition of Zhihu
[system analyst's road] Chapter 7 double disk system design (service-oriented development method)
Example code of MySQL split string as query condition
js对JSON数组的增删改查
How much does the mlperf list weigh when AI is named?
matplotlib画柱状图并添加数值到图中
Local deployment Zeppelin 0.10.1
【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码
Realize colorful lines and shape your heart
[OFDM communication] OFDM system signal detection based on deep learning with matlab code