1
Follows the code:
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8" />
<title>Passagem de valores com VueJS</title>
</head>
<body>
<div id="app">
<my-ul>
<my-li></my-li>
</my-ul>
</div>
<template id="my-li">
<li v-for="item in items">
{{ item }}
</li>
</template>
<template id="my-ul">
<ul>
<my-li :items="['Bala', 'Chocolate']"></my-li>
</ul>
</template>
<script src="https://unpkg.com/vue"></script>
<script>
Vue.component("my-li", {
template: "#my-li",
props: ["items"],
});
Vue.component("my-ul", {
template: "#my-ul",
data: function() {
return {
}
},
});
var app = new Vue({
el: "#app",
data: {
message: "Hello Vue"
}
});
</script>
</body>
</html>
If I’m just trying to see if prop
items
is being passed this way:
<template id="my-li">
<li>
{{ items }}
</li>
</template>
I got a way out:
[ "Bala", "Chocolate" ]
But when trying to apply the directive v-for
I simply get a blank screen, but I can’t identify where I’m going wrong. Any help is welcome.
Giovane thank you for the answer helped a lot.
– ThiagoO