From 809515e73e6339a869d402496198d13d68db5879 Mon Sep 17 00:00:00 2001 From: xiongqian <2167232911@qq.com> Date: Tue, 31 Jan 2023 09:52:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/regular.ts | 8 ++- src/views/device/Product/Save/index.vue | 95 ++++++++++++++++++++----- 2 files changed, 84 insertions(+), 19 deletions(-) diff --git a/src/utils/regular.ts b/src/utils/regular.ts index 9d88336f..7e7fa9cc 100644 --- a/src/utils/regular.ts +++ b/src/utils/regular.ts @@ -1,4 +1,10 @@ // 用于校验 url export const urlReg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; -export const isUrl = (path: string): boolean => urlReg.test(path) \ No newline at end of file +export const isUrl = (path: string): boolean => urlReg.test(path) + +// 用于校验只允许输入英文或者数字或者-或者_ + +export const inputReg = /^[a-zA-Z0-9_\-]+$/ + +export const isInput = (value: string) => inputReg.test(value) \ No newline at end of file diff --git a/src/views/device/Product/Save/index.vue b/src/views/device/Product/Save/index.vue index 1c928ba6..5958a65c 100644 --- a/src/views/device/Product/Save/index.vue +++ b/src/views/device/Product/Save/index.vue @@ -13,7 +13,7 @@ width="650px" >