初始化代码
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {ref} from 'vue'
|
||||
|
||||
export const useNavStore = defineStore(
|
||||
'nav',
|
||||
() => {
|
||||
const navIndex = ref('/')
|
||||
|
||||
const changeNavIndex = (id) => {
|
||||
if (!id) {
|
||||
return
|
||||
} else {
|
||||
navIndex.value = id
|
||||
console.log(localStorage.getItem('nav'))
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
navIndex,
|
||||
changeNavIndex,
|
||||
}
|
||||
},
|
||||
{
|
||||
persist: true,
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user