1. export default {
    2. componentUpdated (el, binding) {
    3. if (binding.value === undefined) {
    4. return
    5. }
    6. let body = document.body
    7. if (binding.value) {
    8. let scrollTop = body.scrollTop || document.documentElement.scrollTop
    9. document.body.style.cssText += 'position:fixed;width:100%;top:-' + scrollTop + 'px;'
    10. } else {
    11. body.style.position = ''
    12. let top
    13. if (body.style.top) {
    14. top = body.style.top
    15. } else {
    16. top = document.body.scrollTop || document.documentElement.scrollTop
    17. }
    18. document.body.scrollTop = document.documentElement.scrollTop = Math.abs(parseInt(top))
    19. body.style.top = ''
    20. }
    21. }
    22. }