How do I use Pinia getters defined in my store in my component templates?
With Vuex, I can do this.$store.getters.getterName(params)
.
Here is my attempt using Pinia.
<script lang="ts">
import { useStore } from "@/store/store";
export default {
setup() {
const store = useStore;
return {
store,
};
},
};
</script>
<template>
<h1>{{ store.getterName(params) }}</h1>
</template>
You forgot to call useStore
inside setup
.
export default {
setup() {
const store = useStore();
return {
store,
};
},
};