-
-
Save eladcandroid/75c9dbaf13d80602b4636b1060d09757 to your computer and use it in GitHub Desktop.
Change to Vue Composition Api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
<script> | |
import { ref, onMounted, onUnmounted } from '@vue/composition-api' | |
export default { | |
setup(props) { | |
const pageOffset = ref(0) | |
const update = () => { | |
pageOffset.value = window.pageYOffset | |
} | |
onMounted(() => window.addEventListener('scroll', update)) | |
onUnmounted(() => window.removeEventListener('scroll', update)) | |
return { | |
pageOffset | |
} | |
} | |
} | |
</script> | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment