From fc33bec5642dbec51988ad54aa72a2006cec43e3 Mon Sep 17 00:00:00 2001 From: riverflow <3011499946@qq.com> Date: Sun, 10 Aug 2025 13:29:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=9C=A8HelloWorld.vue=E4=B8=AD=E5=AF=BC?= =?UTF-8?q?=E5=85=A5store=EF=BC=8C=E5=B9=B6=E8=8E=B7=E5=8F=96store?= =?UTF-8?q?=EF=BC=8C=E6=B5=8B=E8=AF=95=E5=BC=95=E5=85=A5=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=88=90=E5=8A=9F=20=EF=BC=88=E6=B5=8B=E8=AF=95=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E2=80=94=E5=BC=95=E5=85=A5=E6=88=90=E5=8A=9F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order-system/src/components/HelloWorld.vue | 13 ++++++++----- order-system/src/store/test/index.ts | 2 +- order-system/src/vite-env.d.ts | 12 +++++++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/order-system/src/components/HelloWorld.vue b/order-system/src/components/HelloWorld.vue index a044e4d..18e8768 100644 --- a/order-system/src/components/HelloWorld.vue +++ b/order-system/src/components/HelloWorld.vue @@ -1,6 +1,10 @@ @@ -9,11 +13,10 @@ import { ref } from 'vue'

测试Element-plus是否引入成功

Default - Primary - Success - Info - Warning - Danger +
+

测试store是否引入成功

+ {{ store.count }} +
diff --git a/order-system/src/store/test/index.ts b/order-system/src/store/test/index.ts index a6d9668..3b2731a 100644 --- a/order-system/src/store/test/index.ts +++ b/order-system/src/store/test/index.ts @@ -4,7 +4,7 @@ import { defineStore } from 'pinia' // 但最好含有 store 的名字,且以 `use` 开头,以 `Store` 结尾。 // (比如 `useUserStore`,`useCartStore`,`useProductStore`) // 第一个参数是你的应用中 Store 的唯一 ID。 -export const testStore = defineStore('testStore', { +export const useTestStore = defineStore('testStore', { // state可以理解为一个共享的内存 state: () => { return { diff --git a/order-system/src/vite-env.d.ts b/order-system/src/vite-env.d.ts index e6e3d3b..04b550a 100644 --- a/order-system/src/vite-env.d.ts +++ b/order-system/src/vite-env.d.ts @@ -15,9 +15,19 @@ declare module '*.vue' { export default component } -// 声明路径别名(可选,增强类型提示) +// 声明路径别名 declare module '@/components/*' { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> export default component } + +// 添加以下 Pinia 和路径别名支持 +declare module 'pinia'; +declare module '@/store/*' { + import { StoreDefinition } from 'pinia'; + // 允许导出任意具名成员 + export const useTestStore: StoreDefinition; + // 或者更通用的声明方式 + export function useTestStore(): any; +} \ No newline at end of file -- 2.34.1 From ef83c1c79623f3f32c78e3181014ed75ee406270 Mon Sep 17 00:00:00 2001 From: riverflow <3011499946@qq.com> Date: Sun, 10 Aug 2025 13:35:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=BB=99=E6=8C=89=E9=92=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6=EF=BC=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BF=AE=E6=94=B9store=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E5=80=BC=20=EF=BC=88=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E2=80=94=E4=BF=AE=E6=94=B9=E6=88=90=E5=8A=9F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order-system/src/components/HelloWorld.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/order-system/src/components/HelloWorld.vue b/order-system/src/components/HelloWorld.vue index 18e8768..f2510a9 100644 --- a/order-system/src/components/HelloWorld.vue +++ b/order-system/src/components/HelloWorld.vue @@ -5,14 +5,17 @@ import { ref } from 'vue' import { useTestStore } from '@/store/test' const store = useTestStore() - +// 改变store里面count的值 +const addBtn =() =>{ + store.count++ +}