1
我有這樣的代碼如何從父母傳遞refrence兒童在VUE JS
HTML
<div class="col-xs-4">
<h3 class="text-center">Incomplete task</h3>
<div class="well" style="max-height: 300px;overflow: auto;">
<ul id="check-list-box" class="list-group checked-list-box">
<li v-for="task in incompleteTasks" class="list-group-item">
<input type="checkbox" name="" @click="addToDone">
{{task.description}}
</li>
<!-- <li v-for="task in incompleteTasks" v-text="task.description" class="list-group-item">
<input type="checkbox" class="" /></li> -->
</ul>
<br />
</div>
</div>
而且我JS貌似這個
let data = {
heading:'Task List',
tasks :[
{description: 'GO to store', completed : false},
{description: 'SignUp Page', completed :false },
{description: 'Create New team', completed : false},
{description: 'Add Entity', completed : false},
{description: 'Add WorkFlow', completed : false}
]
};
new Vue({
el: '#root',
data: data,
methods: {
addToDone() {
this.completed = true;
console.log(this);
},
},
computed: {
heading() {
return this.heading;
},
incompleteTasks() {
return this.tasks.filter(task => !task.completed);
},
completeTasks() {
return this.tasks.filter(task => task.completed);
}
}
})
的onclick複選框我想將該li的對象的完成屬性切換爲True
我該怎麼做?
感謝
@SrinivasDaman哦不錯!好吧就像普通的js然後 – Vikram
我看到了,我只是想告訴你可以用'index'來做到這一點。 –