스크롤 동작

1697 단어



    
    Document
    
    
    


    
index list {{flag}}
var index={ data:function(){ return{ name:"jay" } }, // beforeRouteEnter:function(to,from,next){ // setTimeout(function(){ // next(function(vm){ // vm.name="jay" // }); // },2000) // }, beforeRouteLeave:function(to,from,next){ console.log("update"); next(); }, template:"<h1 class='index'>{{name}}</h1>" } var list={ template:"<h1 class='list'>list</h1>" } var app=new Vue({ el:"#app", data:{ flag:false }, created:function(){ this.$router.beforeEach(function(to,from,next){ // window.scrollTo(0,0); document.documentElement.scrollTop=0; next(); }) }, router:new VueRouter({ routes:[ { path:"/", component:index }, { path:"/list", component:list } ] }) })

좋은 웹페이지 즐겨찾기