AGENT SKILL
pinia-state
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-06-24
- Stars
- ★ 67
- Forks
- 24
03 SKILL.md 正文
Pinia
Store
import { defineStore } from 'pinia';
export const useAuthStore = defineStore('auth', () => {
const user = ref<User | null>(null);
const isLoggedIn = computed(() => !!user.value);
async function login(email: string, pass: string) {
user.value = await api.login(email, pass);
}
return { user, isLoggedIn, login };
});
Usage
<script setup>
const auth = useAuthStore();
const { isLoggedIn } = storeToRefs(auth);
</script>