hasOwnProperty(),propertyIsEnumerable( ) ,isPrototypeOf( )

1.hasOwnProperty( )方法用来检测某个属性是否是对象的自身属性(继承的属性不是自身属性,原型属性也不属于)。

2.propertyIsEnumerable( ) 只有检测到是自身属性且这个属性是可枚举的返回true,某些内置属性是不可枚举的。

3.isPrototypeOf( ) 这个方法会告诉我们当前对象是否是一个对象的原型(即子类)。

子类对象 . isPrototypeOf( ) ( 父类对象 )

4.instanceof 判断一个对象是否是一个构造器的实例。

5.typeof 返回对象的类型。


为啥自定义校验// 提取出来的密码校验函数 const validatePasswordMatch = (rule: any, value: string, callback: Function) => { console.log('rule:',rule) console.log('value:',value); console.log('callback:',callback); if (!formModel.value.password) { callback(new Error('密码不能为空')) } else if (value !== formModel.value.password) { callback(new Error('两次密码输入不一致')) } else { callback() // 校验通过 } }rule: 123 forgetPsw.vue:51 value: Proxy(Object) {trigger: 'blur', validator: ƒ}[[Handler]]: MutableReactiveHandler[[Target]]: Objecttrigger: "blur"validator: (rule, value, callback) => {…}length: 3name: "validatePasswordMatch"arguments: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at validatePasswordMatch.invokeGetter (<anonymous>:3:28)]caller: [Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at validatePasswordMatch.invokeGetter (<anonymous>:3:28)][[FunctionLocation]]: forgetPsw.vue:49[[Prototype]]: ƒ ()[[Scopes]]: Scopes[3][[Prototype]]: Objectconstructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()__proto__: (...)get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()[[IsRevoked]]: false forgetPsw.vue:52 callback: undefined
03-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值