当前位置:网站首页>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>
边栏推荐
- Interface joint debugging test script optimization v4.0
- DAY FOUR
- Experiment 5: common automation libraries
- Compile logisim
- 【212】php发送post请求有哪三种方法
- JDBC programming of MySQL database
- Implementation steps of mysql start log in docker
- 1000字精选 —— 接口测试基础
- Automatic test tool katalon (WEB) test operation instructions
- 在Docker中分分钟拥有Oracle EMCC 13.5环境
猜你喜欢
Résumé des connaissances de gradle
服务器SMP、NUMA、MPP体系学习笔记。
DAY FIVE
Today, I met a senior test developer from Tencent and saw the ceiling of the foundation
Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
Restoration analysis of protobuf protocol of bullet screen in station B
电脑重装系统u盘文件被隐藏要怎么找出来
1000字精选 —— 接口测试基础
The best sister won the big factory offer of 8 test posts at one go, which made me very proud
Penetration test --- database security: detailed explanation of SQL injection into database principle
随机推荐
The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
DAY SIX
【精品】pinia 基于插件pinia-plugin-persist的 持久化
求帮助xampp做sqlilab是一片黑
Example code of MySQL split string as query condition
[OFDM communication] OFDM system signal detection based on deep learning with matlab code
Laravel8 uses passport authentication to log in and generate a token
氢创未来 产业加速 | 2022氢能专精特新创业大赛报名通道开启!
Matplotlib draws a histogram and adds values to the graph
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
JDBC programming of MySQL database
app通用功能測試用例
设计一个抢红包系统
How does crmeb mall system help marketing?
士大夫哈哈哈
There are only two TXT cells in the ArrayExpress database. Can you only download the sequencing run matrix from line to ENA?
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
The programmer refused the offer because of low salary, HR became angry and netizens exploded
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
Can async i/o be implemented by UDF operator and then called by SQL API? At present, it seems that only datastre can be seen