You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< script setup >
/***
* name: 状态管理 示例
* user: sa0ChunLuyu
* date: 2022-04-13 09:20:12
*/
// Pinia
import { useStore } from "~/store" ;
const $store = useStore ( )
// Pinia end
// Session
const session _count = useStorage ( 'session_count' , 0 , sessionStorage )
// Session end
// Local
const local _count = useStorage ( 'local_count' , 0 )
// Local end
< / script >
< template >
< tr >
< td > Pinia < / td >
< td > { { $store . count } } < / td >
< td >
< n -space >
< n -button secondary strong @click ="$store.count++" > 增 加 < / n -button >
< n -button secondary strong @click ="$store.count--" > 减 少 < / n -button >
< / n - s p a c e >
< / td >
< / tr >
< tr >
< td > Session < / td >
< td > { { session _count } } < / td >
< td >
< n -space >
< n -button secondary strong @click ="session_count++" > 增 加 < / n -button >
< n -button secondary strong @click ="session_count--" > 减 少 < / n -button >
< / n - s p a c e >
< / td >
< / tr >
< tr >
< td > Local < / td >
< td > { { local _count } } < / td >
< td >
< n -space >
< n -button secondary strong @click ="local_count++" > 增 加 < / n -button >
< n -button secondary strong @click ="local_count--" > 减 少 < / n -button >
< / n - s p a c e >
< / td >
< / tr >
< / template >