12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // //引入pinia
- // import { defineStore } from 'pinia'
- // export const menuStatusStore = defineStore(
- // 'menuStatus',
- // {
- // //状态数据
- // state: () => ({
- // activeIndex: '1'
- // }),
- // //计算属性不能传参
- // getters: {
- // },
- // //action --相当于methods
- // actions: {
- // //对数据进行操作
- // saveActive(val: string) {
- // this.activeIndex = val
- // }
- // },
- // persist: {
- // key: 'piniaStore',
- // storage: sessionStorage,
- // paths: ['activeIndex']
- // }
- // }
- // )
- //引入pinia
- import { defineStore } from 'pinia'
- import { ref } from 'vue'
- export const menuStatusStore = defineStore(
- 'menuStatus', () => {
- const activeIndex = ref('1')
- const saveActiveIndex = (val: string) => {
- activeIndex.value = val
- }
- return { activeIndex, saveActiveIndex }
- },
- // { persist: true }
- {
- persist: true
- }
- )
|