| | |
| | | store, |
| | | render: h => h(App) |
| | | }) |
| | | //ip验证 |
| | | Vue.directive('ipAddressValidator', { |
| | | bind(el, binding, vnode) { |
| | | el.addEventListener('input', () => { |
| | | const value = el.value; |
| | | // IPv4 address validation |
| | | if (/^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])(\.((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]))){3})$/.test(value)) { |
| | | console.log("Valid IPv4 Address"); |
| | | } else if (!/(^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$)|(^(?:(?:[\x00-\x7F]|[\u0391-\uFFEF])+)(?:\.[a-zA-Z0-9]+)*$)/i.test(value)) { |
| | | console.log("Invalid IPv4 or IPv6 Address"); |
| | | } else { |
| | | console.log("Valid IPv6 Address"); |
| | | } |
| | | }); |
| | | }, |
| | | }); |