-
Default
-
Primary
-
Success
-
Info
-
Warning
-
Danger
+
+
+
+
测试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