baixingwenzheng-pc/node_modules/vooks/es/use-false-until-truthy.js
2024-01-29 09:26:07 +08:00

14 lines
395 B
JavaScript

import { ref, readonly, watch } from 'vue';
export default function useFalseUntilTruthy(originalRef) {
const currentRef = ref(!!originalRef.value);
if (currentRef.value)
return readonly(currentRef);
const stop = watch(originalRef, (value) => {
if (value) {
currentRef.value = true;
stop();
}
});
return readonly(currentRef);
}