mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
fix(packages/vue): set render duration ref only after mounted and updated
This commit is contained in:
@@ -22,9 +22,13 @@ import { getLifeCycleTarger } from '../..';
|
|||||||
export function useRenderInfo(instance?: ComponentInternalInstance) {
|
export function useRenderInfo(instance?: ComponentInternalInstance) {
|
||||||
const target = getLifeCycleTarger(instance);
|
const target = getLifeCycleTarger(instance);
|
||||||
const duration = ref(0);
|
const duration = ref(0);
|
||||||
|
let startTime = 0;
|
||||||
|
|
||||||
const startMark = () => duration.value = performance.now();
|
const startMark = () => startTime = performance.now();
|
||||||
const endMark = () => duration.value = Math.max(performance.now() - duration.value, 0);
|
const endMark = () => {
|
||||||
|
duration.value = Math.max(performance.now() - startTime, 0);
|
||||||
|
startTime = 0;
|
||||||
|
};
|
||||||
|
|
||||||
onBeforeMount(startMark, target);
|
onBeforeMount(startMark, target);
|
||||||
onMounted(endMark, target);
|
onMounted(endMark, target);
|
||||||
|
|||||||
Reference in New Issue
Block a user