default
default(value, [strict=false], [ctx])
作用
设置当被检测值为undefined | null | NaN
时,validate
和validateSilent
方法的返回值。
若开启严格模式(strict=true), 则设置被检测值为undefined | null | NaN | '' | {} | []
时的默认返回值。
参数
value
(*) -validate
和valdiateSilent
默认值,可为任意类型。当value
为函数时,则设置函数的返回值为默认值,函数参数为被检测值原始值——undefined
,null
,NaN
,''
,{}
或[]
.[strict]
(boolean) - 是否为严格模式,默认为false
不开启。若明确设置strict=true
则开启严格模式。[ctx]
(*) - 当value
为函数时的执行上下文this
。
示例
最后更新于
这有帮助吗?