Merge pull request '配置pinia,导入HelloWorld.vue测试(测试通过)' (#5) from Brunch_LPQ into main

pull/11/head
ppnwsfegt 2 months ago
commit a8f2acc6b6

@ -1,19 +1,34 @@
<script setup lang="ts">
import { ref } from 'vue'
import { ref , computed} from 'vue'
// storestore
import { useTestStore } from '@/store/test'
const store = useTestStore()
// storecount
const addBtn =() =>{
// 1
store.count++
// 2
// store.setCount(++store.count)
}
// computed
const count = computed(()=>{
return store.count
})
</script>
<template>
<h1>测试路由搭载是否成功不需要msg</h1>
<h1>测试Element-plus是否引入成功</h1>
<div class="mb-4">
<el-button>Default</el-button>
<el-button type="primary">Primary</el-button>
<el-button type="success">Success</el-button>
<el-button type="info">Info</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
<el-button @click="addBtn">+</el-button>
<div>
<h1>测试store是否引入成功</h1>
{{ count }}
</div>
<el-icon>
<Edit />

@ -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 {

@ -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;
}
Loading…
Cancel
Save