I have a template like this:
<template> <div>{{hello}}</div> </template> <script> export default { data() { hello: "Hello World!", secret: "The answer is 42" } } </script>
How can I get, and manipulate the value of secret
from the Chrome debugging console?
I have installed the Vue extension which allows me to look at my component and see the variables. What I would like to do is to get these variables and manipulate them.
Is this possible?
To create a component, following is the syntax. Vue. component('nameofthecomponent',{ // options}); Once a component is created, the name of the component becomes the custom element and the same can be used in the Vue instance element created, i.e. inside the div with ids component_test and component_test1.
so you can get global variable value and use global variable in vue js. if you define global variable then you can easily access global variable in vuejs app. We will define global variables using vue js mixin. using mixin we will declare all variables in data method.
There is a similar discussion on the Vue.js forum. Specifically, SevenLines post on Mar 25 2018 reads:
Update from 2018. If you use vue-devtools, you can access Vue from console by selecting desired component, and then accessing it through $vm variable. Check the image with example:
I use this
// if result is single element document.getElementById('app').__vue__ // if result is multiple elements document.getElementsByClassName('some-class')[0].__vue__
assuming your using id #app for your entry
can also do it in other elements as long as identified as Vue Component element
and get element by tag/id/class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With