Pinia-面试-插件与持久化
2026年10月16日·Admin·1 次浏览
面试题:Pinia 插件能做什么?持久化怎么做?
插件
$subscribe 监听 mutation、扩展 store、全局拦截 actions(pinia.use)。
持久化
常用 pinia-plugin-persistedstate:把指定 state 同步 localStorage/sessionStorage;注意敏感 token风险与版本迁移。
SSR
持久化与 hydration 需避免服务端与客户端状态不一致闪动。