Name: ...">

The scope of a variable in vue mode

How can I get in Vue something like the following? Psuedo Code:

<div v-context="getPerson(id)">
   <p>Name: {{ $data.name }}</p>
   <p>Age: {{ $data.age }}</p>
</div>
+4
source share
1 answer

It looks like you are returning an object, so you can apply this method and use v-forfor repetition, for example:

<div>
   <p v-for=" (val, key) in getPerson(id)">{{key}}: {{val}}</p>
</div>

The documentation has more information: https://vuejs.org/v2/guide/list.html#Object-v-for

0
source

Source: https://habr.com/ru/post/1681603/


All Articles