自定义按钮失焦指令
export default {
install(app: any, option = {}) {
app.directive('auto-blur', {
mounted(el) {
el.addEventListener("focus", function (e: any) {
let node = e.target;
if (node.tagName == "SPAN") {
node = node.parentNode;
}
node.blur();
}, false);
}
})
}
}
在main.ts文件中全局挂载,使用时在<el-botton>中使用自定义指令 v-auto-blur 即可
import Directive from "@/directive/index";
app.use(Directive)