Guest User

Untitled

a guest
Jan 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <template>
  2. <div>
  3. <header ></header>
  4. <first ></first>
  5. <second ></second>
  6. </div>
  7. </template>
  8.  
  9. <script>
  10. import header from './header.vue'
  11. import first from './first.vue'
  12. import second from './second.vue'
  13. export default {
  14. name: 'main',
  15. data () {
  16. return {
  17. scrollPosition: null
  18. }
  19. },
  20. components: {
  21. first,second,header
  22. },
  23. methods:{
  24. updateScroll() {
  25. this.scrollPosition = window.scrollY
  26. }
  27. },
  28. mounted() {
  29. window.addEventListener('scroll', this.updateScroll)
  30. }
  31. }
  32.  
  33. <template>
  34. <section ref="first">
  35. some content
  36. </section>
  37. </template>
  38. <script>
  39. export default {
  40. mounted: function () {
  41. this.$refs.first.offsetTop // позиция элемента
  42. }
  43. }
  44. </script>
Add Comment
Please, Sign In to add comment