aoscici2000
V2EX  ›  Vue.js

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

  •  
  •   aoscici2000 · Jun 17, 2019 · 2544 views
    This topic created in 2539 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   ·   838 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 21:16 · PVG 05:16 · LAX 14:16 · JFK 17:16
    ♥ Do have faith in what you're doing.