File tree Expand file tree Collapse file tree 2 files changed +30
-14
lines changed
Expand file tree Collapse file tree 2 files changed +30
-14
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ export const directive = {
9797 inserted ( el : any , binding : any ) {
9898 const { arg = "is" , value } = binding ;
9999 const validateFunc = validateFunMaps ?. [ arg ] ;
100- if ( ! validateFunc && ! isType ( validateFunc , "Function" ) ) {
100+ if ( ! validateFunc && ! isType < Function > ( validateFunc , "Function" ) ) {
101101 return ;
102102 }
103103 const hasPermission = validateFunc ( value ) ;
Original file line number Diff line number Diff line change 11/**
22 * 简单的工具集
3- *
3+ *
44 */
55
6- export function isType ( value : any , type : string ) : boolean {
7- return Object . prototype . toString . call ( value ) . includes ( type ) ;
6+ /**
7+ * 获取值的类型,并返回全小写的字符串
8+ * @export
9+ * @param {* } value
10+ * @returns {string } 全小写的字符串
11+ */
12+ export function getType ( value : any ) : string {
13+ return Object . prototype . toString . call ( value ) . slice ( 8 , - 1 ) . toLowerCase ( ) ;
14+ }
15+
16+ /**
17+ * 判断值的类型
18+ * @param value 目标值
19+ * @param type 目标类型
20+ * @returns boolean
21+ */
22+ export function isType < P > ( value : any , type : string ) : value is P {
23+ return getType ( value ) === type . toLowerCase ( ) ;
824}
925
1026export function isBlankValue ( param : any ) : boolean {
11- const noVal = [ '' , null , NaN , undefined ] . includes ( param ) ;
12- if ( noVal ) return true ;
13- if ( Array . isArray ( param ) ) {
14- return param . length === 0 ;
15- }
16- if ( typeof param === ' object' ) {
17- return Object . keys ( param ) . length === 0 ;
18- }
19- return false ;
20- }
27+ const noVal = [ "" , null , NaN , undefined ] . includes ( param ) ;
28+ if ( noVal ) return true ;
29+ if ( Array . isArray ( param ) ) {
30+ return param . length === 0 ;
31+ }
32+ if ( typeof param === " object" ) {
33+ return Object . keys ( param ) . length === 0 ;
34+ }
35+ return false ;
36+ }
You can’t perform that action at this time.
0 commit comments