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" >
- + @@ -83,7 +83,7 @@ - + - + - + + - + - + @@ -193,12 +197,15 @@