<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>

<div id="vue-instance">

    <ol>
        <todo-item v-for="item in lista" v-bind:todo="item"></todo-item>
    </ol>

</div>

<script src="https://cdn.jsdelivr.net/vue/2.1.6/vue.js"></script>

<script>
Vue.component('todo-item', {
    props: ['todo'],
    template: '<li>{{todo.text}}</li>'
})
var vm = new Vue({
    el: '#vue-instance',
    data: {
        lista: [
            {text: 'vegetais'},
            {text: 'queijo'},
            {text: 'vinho'}
        ]
    }
});
</script>

</body>
</html>

attributes are known as props (short for “properties”) and they’re how components talk to each other

results matching ""

    No results matching ""