wujingjing
2024-12-12 bdcd8e12b62ec5e049271a492fd2fd7e18c90490
src/directive/customDirective.ts
@@ -1,4 +1,4 @@
import type { App } from 'vue';
import { nextTick, type App } from 'vue';
const map = new WeakMap();
const ob = new ResizeObserver((entries) => {
   for (const entry of entries) {
@@ -203,13 +203,18 @@
   });
};
export const eleFocusDirective = (app: App) => {
   app.directive('elInputFocus', {
      mounted: (el) => {
         el.querySelector('input.el-input__inner')?.focus();
      mounted: (el, binding: any) => {
         const inputInner = el.querySelector('input.el-input__inner');
         inputInner?.focus();
         // 选中 input 中的所有内容
         // 判断是否绑定值有要选中
         if (binding.value) {
            nextTick(() => {
               inputInner?.select();
            });
         }
      },
   });
};
};