Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
增加滚动支持
页面增加上下滚动事件,并支持回调时候回到原来位置。
  • Loading branch information
MyLittleStone committed Nov 16, 2018
commit ba2032d23c24beb7ef7a289cfc39f944d53f3f4f
20 changes: 18 additions & 2 deletions src/components/layout/src/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<slot name="top"></slot>

<section class="yd-scrollview" ref="scrollView" id="scrollView">
<section class="yd-scrollview" ref="scrollView" id="scrollView" @scroll="scroll">
<slot></slot>
</section>

Expand All @@ -23,14 +23,30 @@
<script type="text/babel">
export default {
name: 'yd-layout',
data(){
return {scrollTop:0};
},
props: {
link: String,
title: String,
showNavbar: {
type: Boolean,
default: true
},
onScroll:{
type:Function,
default:null
}
}
},
methods: {
scroll() {
this.scrollTop=event.target.scrollTop;
this.onScroll&&this.onScroll(event,this);
}
},
activated(){
this.$refs['scrollView'].scrollTop = this.scrollTop;
},
}
</script>

Expand Down