UNPKG

md-input-check

Version:

自定义指令完成ElementUI中el-input数据输入限制。

1 lines 1.71 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.InputCheck=t():e.InputCheck=t()}(this,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>i});var n={toNonNegInt:function(e){return null==e||""===e.replace(/\D/g,"")?"":parseInt(e)},toPosInt:function(e){return null==e?"":e.replace(/\D/g,"")},toFixed2:function(e){if(null==e)return"";var t=e+"";if(t.includes(".")){var n=t.split(".");t=n[0]+"."+n[1].slice(0,2)}return(t=t.replace(/[^\d.]/g,"")).indexOf(".")!==t.lastIndexOf(".")&&(t=t.substring(0,t.indexOf(".")+1)+t.substring(t.indexOf(".")+1).replace(/\./g,"")),t}},r={bind:function(e,t,r){var a;if(a="INPUT"===e.tagName||"TEXTAREA"===e.tagName?e:e.getElementsByTagName("input")[0]||e.getElementsByTagName("textarea")[0]){var i=!1;a.handler=function(){if(!i&&t&&n.hasOwnProperty(t.value)){var o=n[t.value](a.value);if(a.value=o,i=!0,"INPUT"===e.tagName||"TEXTAREA"===e.tagName){var u=new Event("input",{bubbles:!0});e.dispatchEvent(u)}else r.componentInstance.$emit("input",o);i=!1}},a.addEventListener("input",a.handler)}},unbind:function(e){var t=e.getElementsByTagName("input")[0];t&&t.handler&&t.removeEventListener("input",t.handler)}};"undefined"!=typeof window&&window.Vue&&a(window.Vue);var a=function(e){e.directive("input-check",r)};const i=a;return t})()));