-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Version
2.3.4
Reproduction link
https://jsfiddle.net/kxemxsjy/1/
Steps to reproduce
The JsFiddle was created by a gentleman on Vue help forum, it's not a complete replicate of the problem, but it's a good starting point for my testing.
- Put something random to be cached by keep-alive in the card component
- Wrap keep-alive around card components directly (components won't rendered at all)
- Wrap keep-alive around card components directly and key the
keep-alive
(components won't rendered at all) - Wrap keep-alive around
transition-group
(components rendered, but nothing gets cached) - Specify name using
include
doesn't help either
What is expected?
Rating status (in rating component) should be kept for all cards correspondingly
What is actually happening?
Nothing's kept or the card components just not rendered at all due to Vue needs all items to be keyed (Which doesn't quite make sense for keep-alive...)
I went ahead and keyed the keep-alive anyway, but still no luck
I've been stuck on this issue for long enough, I think it's probably time to reach out for some help...
I have a search interface which displays results as card
(using v-for), it will be switched to a different view card-reveal
when user click on it.
There is a component inside each card
called UserRating
from which I want the rating info to be kept when users switch to card-reveal
. I thought it was an obvious keep-alive
case where the documentation seems to be quite straight forward. However, no matter where I wrap the keep alive (with target name), it just doesn't work... Some help would be appreciated. Thanks.
##Partial DOM structure for card
and card-reveal
<div class="results-area">
More code here...
<keep-alive include="UserRating">
<transition-group name="card" tag="div">
<Card v-if="expansionReady"
v-for="result in apiResults"
:result="result"
:key="result.id" />
</transition-group>
</keep-alive>
More code here...
<transition name="slideIn" tag="div">
<CardReveal v-if="expansionMode" :result="currentApiResult" />
</transition>
</div>
##Here is what UserRating
component look like:
<template>
<div class="user-rating">
<i class="material-icons results-rate-up"
:class="{toggled: rateStatus > 0}"
@click.stop="userRate('up')">thumb_up</i>
<i class="material-icons results-rate-down"
:class="{toggled: rateStatus < 0}"
@click.stop="userRate('down')">thumb_down</i>
<span class="accuracy-score tooltipped"
data-position="top"
data-delay="50"
data-tooltip="Accuracy Score"
v-text="accuracyScore"
v-show="accuracyScore !== 0">
</span>
</div>
</template>