Sometimes, we want to get data as object with Vue.js.
In this article, we’ll look at how to get data as object with Vue.js.
How to get data as object with Vue.js?
To get data as object with Vue.js, we can use the this.$data
property.
For instance, we write
<script>
export default {
//...
methods: {
log() {
console.log(this.$data.a);
console.log(this.$data.b);
console.log(this.$data.foo);
},
},
//...
};
</script>
to get the a
reactive property with this.$data.a
.
Likewise, we get the b
reactive property with this.$data.b
and the foo
reactive property with this.$data.foo
.
Conclusion
To get data as object with Vue.js, we can use the this.$data
property.