Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do to use Pinia getters in Vue template?

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>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You forgot to call useStore inside setup.

export default {
  setup() {
    const store = useStore();

    return {
      store,
    };
  },
};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading