devtools: bug: Pinia panel not exist on vue devtools
Version
6.1.4
Browser and OS info
Chrome 100.0.4896.88 / macOS 12.3
Steps to reproduce
# 1. create project
$ npm create vite@latest vue3-ts-pinia -- --template vue-ts
# install pinia
$ npm i -S pinia
// 2. use pinia
import { createApp } from 'vue';
import App from './App.vue';
import { createPinia } from 'pinia';
const app = createApp(App);
// const pinia = createPinia();
// app.use(pinia);
app.use(createPinia());
createApp(App).mount('#app');
// 3. create store
import { defineStore } from 'pinia';
export const appStore = defineStore('appStore', {
state() {
return {
msg: "Hello World!",
};
},
getters: {
// computed
getMsg(): string {
return `👻 ${this.msg}`;
}
},
actions: {
// methods
updateMsg(str: string) {
this.msg = str;
},
async fetchData(url: string) {
const json = await fetch(url).then(res => res.json());
// console.log('json =', json);
return json;
},
},
});
<!-- 4. use store -->
<template>
<template v-if="true">
<div>{{store.msg}}</div>
</template>
<template v-if="true">
<div>{{store.getMsg}}</div>
<pre>❓ {{store.msg}}</pre>
<span v-pre>{{ this will not be compiled }}❓ {{store.msg}}</span>
<button @click="updateMsg">Pinia 🍍</button>
</template>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { appStore } from "../store/index";
const store = appStore();
const log = console.log;
log(`store =`, store);
const updateMsg = () => {
store.$patch({
msg: "Hello Pinia 🍍!",
});
// store.updateMsg('Pinia 🍍');
}
let jsonString = ref('');
const url = `https://cdn.xgqfrms.xyz/json/cat.json`;
// async await
store.fetchData(url).then(json => {
jsonString.value = JSON.stringify(json, null, 4);
});
</script>
{
"name": "vue3-ts-pinia",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"pinia": "^2.0.13",
"vue": "^3.2.25"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.1",
"typescript": "^4.5.4",
"vite": "^2.9.2",
"vue-tsc": "^0.29.8"
}
}
- run
npm run dev
and openhttp://localhost:3000/
What is expected?
Pinia panel exists on vue devtools and works well ✅
What is actually happening?
Pinia panel does not exist on vue devtools ❌
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 13
- Comments: 15 (1 by maintainers)
Commits related to this issue
- vue devtools & pinia bug https://github.com/vuejs/devtools/issues/1839 — committed to xgqfrms/Vue-3.x by xgqfrms 2 years ago
- bug: pinia devtools https://github.com/vuejs/devtools/issues/1839 — committed to xgqfrms/Vue-3.x by xgqfrms 2 years ago
- fix: pinia not in devtools https://github.com/vuejs/devtools/issues/1839 — committed to paotuan/qqchannel-bot by maliut 10 months ago
- chore: rearange pinia init to fix panel in vue devtools See https://github.com/vuejs/devtools/issues/1839 for more details. — committed to philharmoniedeparis/metascore-library by semiaddict 4 months ago
solutions ✅
what worked for me was
app.use(createPinia()) and then making it the last just before app.mount(‘#app’)
any idea how to do this in vue2?
@bernardoadc moving the pinia instance towards the end of Vue’s constructor args did the trick for me, though not sure why:
I just wanted to let you know that it works for me.
@Akryum yeah, I did that.
Did you do the pinia setup in your app?
Using quasar, the following worked for me:
A solution that worked for me was to force it with another Chrome extension: https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd