zoukankan      html  css  js  c++  java
  • vue 浏览器滚动行为

    import Vue from 'vue'
    import App from './App.vue'
    import VueRouter from 'vue-router'
    import {routes} from './routes'
    Vue.use(VueRouter)
    
    const router =new VueRouter({
      routes ,
      mode:'history',
      scrollBehavior(to,from,savedPosition){
        //浏览器滚动行为
        //return {selector:'.btn'};
        //return {x:0,y:100};
        if(savedPosition){
          return savedPosition;
        }else{
          return {x:0,y:0}
        }
      }
    })
    //全局守卫
    /*router.beforeEach((to,from,next)=>{
      //alert("还没有登录,请先登录");
     // next();
      //判断store.gettes.isLogin ===false
      if(to.path == '/login'||to.path == '/register'){
        next();
      }else{
        alert("还没有登录,请先登录");
        next('/login');
      }
    
    })*/
    //后置钩子
    /*router.afterEach((to,from)=>{
      alert("after each");
    })*/
    new Vue({
      el: '#app',
      router,
      render: h => h(App)
    })

    浏览器滚动行为:第一种到制定的位置

    第二张到制定的标签或者id位置

    第三种,到上次浏览的位置

  • 相关阅读:
    os模块
    sys模块
    time时间模块
    collections模块
    修改Jenkins的主目录步骤
    jenkins管理
    求2个集合的差集
    MVC动态二级域名解析
    解决MVC 时间序列化的方法
    MVC修改视图的默认路径
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10707314.html
Copyright © 2011-2022 走看看