[Vuejs]-Pinia reading getter from another getter

0👍

I can offer you an alternative, Vue 3 works much better with Composition APi, faster, more intuitive and easier to understand, this is how I handle it and it does not cause conflicts and little by little your application is scaling

import { defineStore } from 'pinia'
import { ref } from 'vue

export const useMyStore = defineStore('myStore',() => {
const state1 = ref(100);

const getterName1 = () => state1.value * 100
const getterName2 = () => state1.value - 100

return {state1,getterName1, getterName2}
})

and now you can use it in any component like this

import {useMyStore} from 'yourpath/'
const useStore = useMyStore

const test = () => {
useStore.getterName1()
}

<template>
<p>{{useStore.state1}}</p>
</template>

hope helpfull

Leave a comment