Skip to content

Commit

Permalink
Solved the scopedSlot issue of latest vue
Browse files Browse the repository at this point in the history
A bug exists in current vue(v2.6.11): `v-if` evaluated `false` when component utilized by `<template v-slot="...">` or `<template slot-scope="...">`. This makes `:item` virtually inaccessible. See the issue here: [vue issue#11084](vuejs/vue#11084).
Here's the workaround: replace `$slots` with `$scopedSlots`.
  • Loading branch information
wilsonlmh committed Mar 4, 2021
1 parent f1a866f commit 494ef34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/VueHorizontalTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<ol>
<li v-for="(item, i) in items" :key="i" :style="setLineColor">
<div class="time" :class="getTimeClass(item)" :style="getTimeStyles" @click="cardClicked(item)">
<slot v-if="$slots.default" v-bind:item="item"/>
<slot v-if="$scopedSlots.default" v-bind:item="item"/>
<span
class="title"
v-if="!$slots.default && item[titleAttr]"
v-if="!$scopedSlots.default && item[titleAttr]"
:class="getTitleClasses">
{{ item[titleAttr] | textSubstr(titleSubstr) }}
</span>
<span
class="content"
v-if="!$slots.default && item[contentAttr]"
v-if="!$scopedSlots.default && item[contentAttr]"
:class="getContentClasses">
{{ item[contentAttr] | textSubstr(contentSubstr) }}
</span>
Expand Down

0 comments on commit 494ef34

Please sign in to comment.