2017-03-01 50 views
0

我有一个看起来像这样的组件:VUE定制发出不工作的V-的

<task-list :content="lesson.children" :iterator="lesson.section" :user="user" @updateTask="updateTask"></task-list> 

我使用的组件在2个不同的网页。在页面上的插入,就像是,在另一页其父是V型的,所以它看起来像:

<div class="lesson-list-item" v-bind:class="{ 'lesson-complete': course.iterator_position > index}" v-for="(lesson, index) in content" > 

    <task-list :content="lesson.children" :iterator="lesson.section" :user="user" @updateTask="updateTask"></task-list> 

</div> 

两个页面有方法:

updateTask(index){ 

       var self = this; 

       this.loaded  = false; 
       this.iterator = index; 
       this.newTask = index; 
       setTimeout(function() { self.loaded = true }, 10); 

      } 

这是任务列表发出一个点击:

cardClick(index, slug, initialIterator){ 

       console.log(index); 

       if(index <= this.initialIterator){ 
        this.$emit('updateTask', index); 
       } 

      } 

那里它不是裹在v-for作品的页面,这是从来没有收到信号发送的事件之一。

+0

您可能要包括发出了'updateTask'事件的代码。并澄清你的意思是“不起作用”,或者包含指向展示该问题的jsFiddle的链接。 – PatrickSteele

+0

@patricksteele我刚刚更新了问题 – Packy

+1

@patricksteele感谢提及updateTask emit。它以一种可以在一页上触发但不是另一种触发的方式进行包装,因此它很有意义。我专注于错误的区域 – Packy

回答

0

我认为你的组件不会发出updateTask事件。

一下添加到您想要触发事件的方法:this.$emit('updateTask');

+0

任务列表组件发出的事件很好,但只有在“”不在v-for中时才会收到。当我确实有''''updateTask'方法正常工作。 – Packy