Git Product home page Git Product logo

Comments (8)

Elikke-007 avatar Elikke-007 commented on June 5, 2024 1

我因为之前不小心把虚拟列表父容器的高度改成100%,以致于虚拟列表失效了,然后使用keep-alive组件的出现了问题,
后来发现并改成100vh之后就不会了。

from vue-virtual-waterfall.

lhlyu avatar lhlyu commented on June 5, 2024

我没有重现出来这种情况,你有例子的源码吗

from vue-virtual-waterfall.

Elikke-007 avatar Elikke-007 commented on June 5, 2024

可以贴一下您的例子代码吗?我看看是哪里不同

from vue-virtual-waterfall.

lhlyu avatar lhlyu commented on June 5, 2024
  • App.vue的代码
<router-view v-slot="{ Component, route }">
    <keep-alive>
        <component :is="Component" :key="route.name" />
    </keep-alive>
</router-view>

路由就两个页面一个是Example.vue,加了一个按钮跳转到Other.vue的页面,然后Other.vue有个按钮跳转到Example.vue

from vue-virtual-waterfall.

Elikke-007 avatar Elikke-007 commented on June 5, 2024

我使用了 <keep-alive include="waterfall"></keep-alive>才出现问题,请问要怎么指定单独一个路由保持状态?因为其他页面我不需要保持,但是不指定路由的话,其他页面也保持了

from vue-virtual-waterfall.

Elikke-007 avatar Elikke-007 commented on June 5, 2024

我的代码确实是错误的,使用<keep-alive include="waterfall"></keep-alive>报错了,请问要怎么指定单独一个路由保持状态?

from vue-virtual-waterfall.

lhlyu avatar lhlyu commented on June 5, 2024

我看了一下官方的定义:

interface KeepAliveProps {
  /**
   * 如果指定,则只有与 `include` 名称
   * 匹配的组件才会被缓存。
   */
  include?: MatchPattern
  /**
   * 任何名称与 `exclude`
   * 匹配的组件都不会被缓存。
   */
  exclude?: MatchPattern
  /**
   * 最多可以缓存多少组件实例。
   */
  max?: number | string
}

只要include指定组件的名字就好了,比如我的Example.vue的默认名字就是Example,然后向下面一样指定就好了

<router-view v-slot="{ Component, route }">
    <keep-alive include="Example">
        <component :is="Component" :key="route.name" />
    </keep-alive>
</router-view>

from vue-virtual-waterfall.

Elikke-007 avatar Elikke-007 commented on June 5, 2024

感谢大佬耐心教导,谢谢!祝您生活愉快!

from vue-virtual-waterfall.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.