feat(TagsView): Add TagsView component
feat(ContextMenu): Add ContextMenu component feat(store): Add tagsView store
This commit is contained in:
@@ -38,3 +38,24 @@ export const underlineToHump = (str: string): string => {
|
||||
export const setCssVar = (prop: string, val: any, dom = document.documentElement) => {
|
||||
dom.style.setProperty(prop, val)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找数组对象的某个下标
|
||||
* @param {Array} ary 查找的数组
|
||||
* @param {Functon} fn 判断的方法
|
||||
*/
|
||||
// eslint-disable-next-line
|
||||
export const findIndex = <T = Recordable>(ary: Array<T>, fn: Fn): number => {
|
||||
if (ary.findIndex) {
|
||||
return ary.findIndex(fn)
|
||||
}
|
||||
let index = -1
|
||||
ary.some((item: T, i: number, ary: Array<T>) => {
|
||||
const ret: T = fn(item, i, ary)
|
||||
if (ret) {
|
||||
index = i
|
||||
return ret
|
||||
}
|
||||
})
|
||||
return index
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user