Javascript 常用命令
生成UUID
const id = window.crypto.randomUUID()
console.log(id)
// bd4d099b-3d39-4aad-a59c-c45dfac8eaf0
https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript
生成UUID
const id = window.crypto.randomUUID()
console.log(id)
// bd4d099b-3d39-4aad-a59c-c45dfac8eaf0
https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript
To check whether a certain field is valid, use:
检查某个输入是否有效:
$('#myField')[0].checkValidity(); // returns true/false
To check if the form is valid, use:
检查表单是否有效:
$('#myForm')[0].checkValidity(); // returns true/false
If you want to display the native error messages that some browsers have (such as Chrome), unfortunately the only way to do that is by submitting the form, like this:
如果需要显示一些浏览器(如Chrome)的原生错误信息,唯一的方法是通过提交表单:
var $myForm = $('#myForm');
if(! $myForm[0].checkValidity()) {
// If the form is invalid, submit it. The form won't actually submit;
// this will just cause the browser to display the native HTML5 error messages.
$myForm.find(':submit').click();
}
Hope this helps. Keep in mind that HTML5 validation is not supported in all browsers.
希望这有帮助。请记住,并非所有的浏览器都支持HTML5验证。
How to force a html5 form validation without submitting it via jQuery
默认只支持http代理。
带用户认证的代理:http://username:password@127.0.0.1:1080
设置
npm config set proxy http://127.0.0.1:1080
npm config set https-proxy http://127.0.0.1:1080
查看
npm config get proxy
npm config get https-proxy
清除
npm config delete proxy
npm config delete https-proxy
查看所有自定义设置信息
npm config ls