Skip to content

useArrayFindLast

类别
导出大小
204 B
最近修改
2 days ago

反应性 Array.findLast

🌐 Reactive Array.findLast.

用法

🌐 Usage

ts
import { 
useArrayFindLast
} from '@vueuse/core'
const
list
= [
ref
(1),
ref
(-1),
ref
(2)]
const
positive
=
useArrayFindLast
(
list
,
val
=>
val
> 0)
// positive.value: 2

与反应式数组一起使用

🌐 Use with reactive array

ts
import { 
useArrayFindLast
} from '@vueuse/core'
const
list
=
reactive
([-1, -2])
const
positive
=
useArrayFindLast
(
list
,
val
=>
val
> 0)
// positive.value: undefined
list
.
push
(10)
// positive.value: 10
list
.
push
(5)
// positive.value: 5