从子级向父级Vue.js发出多个事件

时间:2020-10-04 02:32:33

标签: vue.js emit

我有一个列表项,它可以向其父项发出2个事件。 第一项赛事运作良好。但是第二个没有。 父组件无法收听。

父母

<review-product-list 
  @showModal="showModalById" 
  @showReportModal="reportModal" 
  lass="grid grid-cols-1 gap-3" 
  :product="product" 
  :reviews="reviews" 
/>

    showModalById(imageId) {
        var index = this.reviewImages
            .map(function (e) {
                return e.id;
            })
            .indexOf(imageId);

        this.indexImage = index;
        this.$modal.show("review-modal");
    },
    reportModal(review_id) {
        this.formReport.review_id = review_id;
        this.$modal.show("report-modal");
    },

儿童 它有效

 <div 
  @click="$emit('showModal', imageId)"
  class="cursor-pointer col-span-12 lg:col-span-3 pb-3 mb-3 lg:pb-0 lg:mb-0 md:border-b lg:border-b-0 lg:border-r border-grey-40 lg:pr-20"
>

不是

<span 
  class="inline-block bg-grey-20 rounded-sm px-3 py-2 text-xs font-medium text-grey-60 cursor-pointer" 
  v-on:click="$emit('showReportModal', review.id)"> 
  Laporkan
</span>

0 个答案:

没有答案