I obtained this particular Store:
export const useMyStore = defineStore('myStore', {
state: () => {
return {
openTransOnly: false,
keyword: '',
openTransStatus: { nextPage: 0, complete: false },
pastDueTransStatus: { nextPage: 0, complete: false },
};
},
getters: {
transStatus(state) {
return state.openTransOnly ? state.openTransStatus : state.pastDueTransStatus;
},
},
});
Now let's suppose I wish to transform the "keyword" attribute above into a Ref. Here is how I accomplished that:
const myStore = useMyStore();
const { keyword: needle } = storeToRefs(myStore);
In addition, there is a computed property in my component:
const page = computed({
get: () => myStore.transStatus.nextPage,
set: (value) => (myStore.transStatus.nextPage = value),
});
which functions properly. Yet, I am interested in learning how to utilize the same "storeToRefs" used earlier to define the "page". I attempted the following:
const { keyword: needle, transStatus: { nextPage: page } } = storeToRefs(myStore);
However, it returns "page is undefined". What mistake am I making? Is this concept feasible?