useComputed

This commit is contained in:
weiwei committed 2025-05-26 19:11:23 +08:00
1 parent 61041d4ae4
commit dff63144ea
1 file changed
+17
+17
View File
@@ -0,0 +1,17 @@
import { computed } from "vue"
const useComputed = (fn: Function) => {
const map = new Map()
return (...args: any[]) => {
const key = JSON.stringify(args)
if (map.has(key)) return map.get(key)
const comput = computed(() => fn(...args))
map.set(key, comput)
return comput
}
}
export default useComputed