Closed SageSanyue closed 3 years ago
@SageSanyue
Hi. We will investigate this issue.
I think I should check a few things before that.
<masonry-infinite-grid :status="status">
code.@daybrush Thanks for your reply.
After using KeepAlive, the components that are wrapped in KeepAlive are cached the first time they are rendered, and the corresponding vnode and DOM are retrieved directly from the cache the next time they are rendered again.
@SageSanyue
Cannot read properties of undefined (reading 'setStatus')
is occur when first rendering
if (this.$refs.ig && this.status) {
}
And use requestAnimationFrame
if (this.$refs.ig && this.status) {
requestAnimationFrame(() => {
this.$refs.ig.setStatus(this.status);
});
}
Sorry, it's maybe my fault. I created a demo using 'keep-alive' run well with '@egjs/vue-infinitegrid'. I'll find the fail reason of the real requirement.
The reson of my fault is not 'keep-alive' but the following 2 reasons. 1.css-'overflow-x: hidden;'. I delete 'overflow-x: hidden;'
2.src/mixins/loadingMixin.js I delete the 'computed'. Before:
const loadingMixin = {
computed: {
isLoading: {
get() {
...
},
set(flag) {
...
},
},
},
created() {
this.isLoading = true;
},
};
export default loadingMixin;
After:
const loadingMixin = {
data() {
return {
isLoading: false
}
},
created() {
this.isLoading = true;
},
};
export default loadingMixin;
Other files: index.vue
<div class="home">
<AppMain />
</div>
...
.home {
position: relative;
min-height: 100%;
// overflow-x: hidden;
background-color: #fbfbfb;}
AppMain.vue
<template>
<ContainerWrapper>
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</ContainerWrapper>
</template>
a.vue (no need of 'getStatus', keepAlive can recognize posion)
<template>
<masonry-infinite-grid
ref="ig"
id="masonry"
class="container"
v-bind:gap="-1"
v-on:request-append="onRequestAppend"
>
<div
class="list_item"
v-for="(item, index) in items"
:key="index"
:data-grid-groupkey="item.groupKey"
>
egjs {{ item.key }}
<a href="/b/id">
<img
width="200"
height="200"
v-bind:src="
'https://naver.github.io/egjs-infinitegrid/assets/image/' +
((item.key % 33) + 1) +
'.jpg'
"
alt="egjs"
/>
</a>
</div>
</masonry-infinite-grid>
</template>
<script>
import { MasonryInfiniteGrid } from "@egjs/vue-infinitegrid";
export default {
...
components: { MasonryInfiniteGrid, }
data() {
return {
items: [],
status: null
}
},
methods: {
...
}
<script>
Description
Excuse me, but I'd like to ask how to restore scroll position with keepAlive?
Steps to check or reproduce
my codes like this: router:
app.vue
a.vue
But when I return page it has error like:
What should I do? Please help.🤕 In fact, the 'items' in
v-for="(item, index) in items"
must use data which was stored in keepAlive. Because as requirement I have to use a button to fetch data of next page instead of 'onRequestAppend'.