生成随机数
普通方法
// 生成随机数
Math.random().toString(36).substr(2);
Symbol
// 生成随机 id 不会重复
const id = Symbol();
大佐的方法,群里大佐提供的
const getUUID = (() => {
// 0n n 代表 bigint
let i = 0n;
return () => {
return (i++).toString(36);
};
})();
const getUUID = (() => {
let i = 123123123234234234234234n;
return () => {
return (i++).toString(36);
};
})();
getUUID();
element ui 对指定字段进行校验
this.$refs[formName].validateField("email", (emailError) => {
// 2 种情况:emailError ='请输入邮箱'或者 emailError =''(所以返回值为空时,验证通过。返回值非空时,验证失败)
if (!emailError) {
alert("邮箱验证通过!");
} else {
console.log("邮箱验证失败");
return false;
}
});
上一篇
Element UI 指定字段校验
本文介绍如何使用 Element UI 对指定表单字段进行校验。代码示例演示了如何使用 `validateField` 方法校验邮箱字段,并根据校验结果进行相应的操作。
下一篇
父元素设置 min-height 后,子元素 height: 100% 无效的解决方法
本文探讨了父元素设置 `min-height` 后,子元素设置 `height: 100%` 无效的问题,并提供了六种有效的解决方法,包括使用 `position: relative/absolute`、Flex 布局、Grid 布局以及 `min-height: inherit` 等,并分析了每种方法的优缺点。