customInstructions.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import Vue from 'vue'
  2. Vue.directive('power', {
  3. inserted(el, type) {
  4. const powerList = [] // JSON.parse(JSON.stringify(utils.getSessionStorage('button')))
  5. const [one, two] = type.value.split(':')
  6. if (one && !powerList.includes(one)) {
  7. if (two === 'tab') {
  8. const idAttr = el.getAttribute('aria-labelledby')
  9. setTimeout(() => {
  10. document.getElementById(idAttr).style.display = 'none'
  11. }, 100)
  12. } else {
  13. el.remove()
  14. // el.style.display = 'none'
  15. }
  16. }
  17. }
  18. })
  19. Vue.directive('mobile-dropdown', {
  20. inserted(el) {
  21. if (window.screen.width < 768) {
  22. el.addEventListener('click', function(event) {
  23. const list = document.querySelectorAll('.el-select-dropdown')
  24. const dom = list[list.length - 1] // console.log(el.offsetLeft, 'offsetLeft') // console.log(event.pageX - event.offsetX +  document.body.scrollLeft, 'total')
  25. const total = event.pageX - event.offsetX + document.body.scrollLeft
  26. dom.style.left = total + 'px'
  27. })
  28. }
  29. }
  30. })