zoukankan      html  css  js  c++  java
  • vue自定义指令

    回到顶部                      js文件

    export default {
    install (Vue) {
    Vue.directive('back-top', {
    inserted (el, binding) {
    let e = binding.arg || 'click'
    el.addEventListener(e, () => {
    var top = document.body.scrollTop
    var timer = setInterval(() => {
    top -= 50
    if (top <= 0) {
    top = 0
    clearInterval(timer)
    }
    document.documentElement.scrollTop = document.body.scrollTop = top
    }, 20)
    })
    }
    })
    }
    }
    

      在mainjs引入       Vue.use('name')

  • 相关阅读:
    12月2号
    11月30号
    11月25号
    本周总结
    每日日报
    每日日报
    每日日报
    JAVA日报
    JAVA日报
    JAVA日报
  • 原文地址:https://www.cnblogs.com/dujunfeng/p/8310914.html
Copyright © 2011-2022 走看看