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) { @@ -202,3 +202,19 @@ }, }); }; export const eleFocusDirective = (app: App) => { app.directive('elInputFocus', { mounted: (el, binding: any) => { const inputInner = el.querySelector('input.el-input__inner'); inputInner?.focus(); // 选中 input 中的所有内容 // 判断是否绑定值有要选中 if (binding.value) { nextTick(() => { inputInner?.select(); }); } }, }); };