v-for prop value not getting updated with bootstrap modal

前端 未结 1 1098
醉梦人生
醉梦人生 2021-01-20 20:28

I have the following code snippet

相关标签:
1条回答
  • 2021-01-20 20:35

    You may need to add key in v-for

    <div class="list-group-item media" v-for="evt in event" :key="evt.id">
        <eventmodal :currentevent="evt"></eventmodal>
    </div>
    

    For the improvement of performance, v-for uses an “in-place patch” strategy and list rendering will not change on child component state or temporary DOM state changes. To track these changes you need to add key attribute with v-for.

    I hope spaces are just typo in <eventmodal :currentevent = "evt"></eventmodal>, remove spaces from :currentevent = "evt".


    Edited

    You are showing same modal everytime, props are being passed correctly, but you are loading the same modal each time.

    You should have dynamic id for each modal like following:

    <eventmodal :id="evt.id" :currentevent="evt"></eventmodal>
    

    and when you are showing this, you should use this dynamic id as following:

    $("#" + event.id).modal()
    
    0 讨论(0)
提交回复
热议问题