1π
β
The <p>
element cannot contain a <div>
, so the browser hoists it outside, resulting in this template:
<p v-for="(verse, verse_index) in verses" :key="verse_index">
</p>
<div v-for="(word, word_index) in verse" :key="word_index">
{{ word }}
</div>
<p></p>
Notice how the second v-for
is outside the first v-for
that defined verse
.
If you really intended to insert the <div>
inside <p>
for some reason, you can workaround the issue by wrapping the <div>
in a <template>
to prevent the browser from parsing it:
<p v-for="(verse, verse_index) in verses" :key="verse_index">
<template> π
<div v-for="(word, word_index) in verse" :key="word_index">
{{ word }}
</div>
</template>
</p>
π€tony19
1π
Not sure if you are passing the data value correctly, but I have changed that a bit and its working fine for me .
data: () => {
return {
verses: [['First', 'Verse'], ['Second', 'Verse']]
}
}
And one suggestion. Its not recommended to use div
tag inside a p
tag
π€Anup
1π
There is nothing wrong with using vue syntax in the above code.
The problem is because <div>
is inside <p>
So this will work
<div v-for="(verse, verse_index) in verses" :key="verse_index">
<div v-for="(word, word_index) in verse" :key="word_index">
{{ word }}
</div>
</div>
π€scar-2018
Source:stackexchange.com