V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
aoscici2000
V2EX  ›  Vue.js

Vue 中回滚到顶部怎么把 keepAlive=true 的排除外?

  •  
  •   aoscici2000 · Jun 17, 2019 · 2482 views
    This topic created in 2517 days ago, the information mentioned may be changed or developed.
    router.beforeEach((to, from, next) => {
      next()
      if (!to.meta.keepAlive) {
        window.scrollTo(0, 0)
      }
    

    如题, 设置了页面跳转的时候需要滚到顶部, 但有些 keepAlive 的页面不需要也滚到顶部, 要怎么弄的,

    1 replies    2019-06-17 07:54:09 +08:00
    JK9993
        1
    JK9993  
       Jun 17, 2019 via iPhone
    加一个或者统一用一个 meta.isScrollTop
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4750 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 10:06 · PVG 18:06 · LAX 03:06 · JFK 06:06
    ♥ Do have faith in what you're doing.