8

How do I access a component data attribute value from the console in Vue 3?

When I was working in vue2 I was accessing this using $vm0 and setting and getting any component attribute value but this does not work in Vue 3.

Vue.js devtools screenshot with data:

enter image description here

Here I want to access isCalendarAttached from Chrome console but I am not able to:

enter image description here

Here is my app object which is the root component:

enter image description here

Is there any way I can access that variable from console?

1 Answer 1

11

As of Vue.js devtools v6.0.0+:

$vm0.ctx.isCalendarAttached // Read-only
$vm0.ctx.$data.isCalendarAttached // Read/Write

Or if your state is moved into setup per Composition API:

$vm0.setupState.isCalendarAttached

Note:

  1. Vue.js devtools v5 does not support Vue 3 so v6 is required.
  2. You'll still need to ensure you've first selected your Vue component in the devtools.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.