I am new to vue, debugging something, and have question: can I print something into the console from Vue getter? For example:
get foo() { console.log(bar); return bar; }
Can I write that line console.log(bar)
?
Thanks!
Advertisement
Answer
Can I write that line
console.log(bar)
?
To answer you question specifically, yes you can do that (assuming bar
is declared within scope).
Did you declare that getter on the Vue instance? If so, that is unusual, and typically you would use a computed property instead.
Using console.log()
as a quick debugging mechanism is fine, but like Wally suggested you should use the Vue dev tools extension for most debugging situations, also in combination with the JavaScript debugger built into your browser.