// directives.js import Vue from 'vue' //select选择器无限滚动 const install = Vue.directive('loadmore', { bind (el, binding) { // 获取element-ui定义好的scroll盒子 const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap') SELECTWRAP_DOM.addEventListener('scroll', function () { const CONDITION = this.scrollHeight - this.scrollTop <= this.clientHeight if (CONDITION) { binding.value() } }) } }) //table无限滚动 const install1 = Vue.directive('loaddata', { bind (el, binding) { // 获取element-ui定义好的scroll盒子 const SELECTWRAP_DOM = el.querySelector('.el-table .el-table__body-wrapper') SELECTWRAP_DOM.addEventListener('scroll', function () { const CONDITION = this.scrollHeight - this.scrollTop <= this.clientHeight if (CONDITION) { binding.value() } }) } }) const input = Vue.directive('onfocus',{ //input框一进来就聚焦,在移动端Safari上autofocus不管用 inserted(el,binding){ // console.log(el) el.firstElementChild.focus(); } }) export {install,input,install1}