aoscici2000
V2EX  ›  Vue.js

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

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