export const useAuthStore = defineStore('auth', {
state: () => ({ Token: '123456' })
// 举例省略了,项目中需要写完整 defineStore
})在 state 中定义并变量都可以在其他位置引入,然后调用:
import { useAuthStore } from 'stores'
const auth = useAuthStore()
console.log(auth.Token)export const useAuthStore = defineStore('auth', {
state: () => ({ Token: '123456' })
// 举例省略了,项目中需要写完整 defineStore
})在 state 中定义并变量都可以在其他位置引入,然后调用:
import { useAuthStore } from 'stores'
const auth = useAuthStore()
console.log(auth.Token)