[update] 1. 跳轉頁面時 scollTop 2. GoToTop btn not work
| | |
| | | margin: 0; |
| | | color: $PRIMARY_BLACK; |
| | | font-family: Segoe UI; |
| | | overflow-x: hidden; |
| | | scroll-behavior: smooth; |
| | | } |
| | | |
| | | html { |
| | | overflow: hidden; |
| | | height: 100%; |
| | | } |
| | | |
| | | body { |
| | | overflow-y: auto; |
| | | height: 100%; |
| | | overflow-x: hidden; |
| | | } |
| | | |
| | | // btn |
| | |
| | | |
| | | created() { |
| | | if (process.browser) { |
| | | window.onscroll = () => { this.scrollFunction() }; |
| | | document.body.addEventListener('scroll', this.scrollFunction); |
| | | } |
| | | } |
| | | |
| | |
| | | document.body.scrollTop = 0; |
| | | document.documentElement.scrollTop = 0; |
| | | } |
| | | |
| | | destroyed() { |
| | | document.body.removeEventListener('scroll', this.scrollFunction); |
| | | } |
| | | } |
| | | </script> |
| | | |
| | |
| | | scss: [ |
| | | '~/assets/scss/main.scss' |
| | | ] |
| | | }, |
| | | router: { |
| | | scrollBehavior (to, from, savedPosition) { |
| | | if (savedPosition) { |
| | | return savedPosition; |
| | | } else { |
| | | document.body.scrollTop = 0; |
| | | document.documentElement.scrollTop = 0; |
| | | } |
| | | } |
| | | } |
| | | } |