Relatively new to Vue. Liking it, but the info on various sources is contradictory which makes it hard to resolve issues.
I have the following code in my twig file:
<test-component data={{ test.jsonData() }}></test-component>
test.jsonData() contains the following:
"{"name":"john","lastName":"doe"}"
So far so good. My Vue component code looks like this
<template>
<div class="test">{{ data }}</div>
</template>
<script>
export default {
props: {
data: {
type: String,
default: "{}"
}
},
mounted: function () {
console.log(this.data);
}
};
</script>
This prints out the data as json. Now, the question is, how can I access it like data.name ? What do I need to change?