当前位置:网站首页>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>
边栏推荐
- Summary of three methods for MySQL to view table structure
- One minute to learn how to install the system, win7 XP, win10 and win11 become very simple
- Example code of MySQL split string as query condition
- 【212】php发送post请求有哪三种方法
- Matplotlib draws a histogram and adds values to the graph
- app通用功能测试用例
- Knowledge * review
- 谁说新消费品牌大溃败?背后有人赢麻了
- MATLIB从excel表中读取数据并画出函数图像
- 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
猜你喜欢

Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN

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

达晨史上最大单笔投资,今天IPO了

【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码
Example code of MySQL split string as query condition

英国都在试行4天工作制了,为什么BAT还对996上瘾?

11 preparations for Web3 and Decentralization for traditional enterprises

浅谈现在的弊端与未来的发展

每年 2000 亿投资进入芯片领域,「中国芯」创投正蓬勃

MVC and MVVM
随机推荐
MATLIB从excel表中读取数据并画出函数图像
A novice asks a question. I am now deployed on a single machine. I submitted an SQL job and it runs normally. If I restart the service job, it will disappear and I will have to
这个『根据 op 值判断操作类型来自己组装 sql』是指在哪里实现?是指单纯用 Flink Tabl
App general function test cases
The same job has two sources, and the same link has different database accounts. Why is the database list found in the second link the first account
Gradle知识概括
Wasserstein Slim GAIN with Gradient Penalty(WSGAIN-GP)介绍及代码实现——基于生成对抗网络的缺失数据填补
One minute to learn how to install the system, win7 XP, win10 and win11 become very simple
If the request URL contains jsessionid, the solution
CRMEB 商城系统如何助力营销?
The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
js导入excel&导出excel
Talking about the current malpractice and future development
Should the jar package of MySQL CDC be placed in different places in the Flink running mode?
士大夫哈哈哈
今日睡眠质量记录78分
Wasserstein slim gain with gradient poverty (wsgain-gp) introduction and code implementation -- missing data filling based on generated countermeasure network
Close unregistering application XXX with Eureka with status down after Eureka client starts
Newsletter L Huobi ventures is in-depth contact with genesis public chain
若依请求url中带有jsessionid的解决办法