Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-11-21 16:09:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4a1513dd4b2e994f5d8f009eb6a325fbbef8e046
4a1513dd
1 parent
49b5e33d
🐞 fix(邮箱组件): 非必填情况下不校验有效性
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
src/components/EmailField/index.vue
src/components/EmailField/index.vue
View file @
4a1513d
<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-
18 10:54:23
* @LastEditTime: 2022-11-
21 16:08:20
* @FilePath: /data-table/src/components/EmailField/index.vue
* @Description: 邮箱输入框
-->
...
...
@@ -28,8 +28,15 @@ const props = defineProps({
item: Object,
});
const pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
const rules = [{ pattern, message: "请输入正确邮箱" }];
const validator = (val) => {
if (!props.item.component_props.required) {
// 非必填
return true;
} else {
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(val);
}
};
const rules = [{ validator, message: "请输入正确邮箱" }];
</script>
<style lang="less" scoped>
...
...
Please
register
or
login
to post a comment