Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
utils
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontEnd
utils
Commits
3a334936
Commit
3a334936
authored
Feb 20, 2019
by
member
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加uitls功能函数
parent
f151f755
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
5 deletions
+53
-5
utils.js
utils.js
+53
-5
No files found.
utils.js
View file @
3a334936
//公共方法
/**
*测试
* params name 姓名
*/
export
const
test
=
function
(
name
)
{
return
name
;
* 从数组中移除指定元素
* @param { arr } 源数组
* @param { item } 要移除的元素
*/
export
function
remove
(
arr
,
item
)
{
if
(
arr
.
length
)
{
const
index
=
arr
.
indexOf
(
item
);
if
(
index
>
-
1
)
{
return
arr
.
splice
(
index
,
1
);
}
}
}
/**
* 检查obj是否具有属性值key
*/
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
export
function
hasOwn
(
obj
)
{
return
hasOwnProperty
.
call
(
obj
,
key
);
}
/**
* 连字符转驼峰
*/
const
camelizeRE
=
/-
(\w)
/g
;
export
function
camelize
(
str
)
{
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
);
}
/**
* 首字母大写
*/
export
function
capitalize
(
str
)
{
return
str
.
charAt
(
0
).
toUpperCase
()
+
str
.
slice
(
1
);
}
/**
* toArray 将类数组对象转为数组
*/
export
function
toArray
(
list
,
start
)
{
start
=
start
||
0
;
let
i
=
list
.
length
-
start
;
const
ret
=
new
Array
(
i
);
while
(
i
--
)
{
ret
[
i
]
=
list
[
i
+
start
];
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment