diff --git a/packages/vue3-lottie/src/vue3-lottie.vue b/packages/vue3-lottie/src/vue3-lottie.vue index 2018acea..1e9c8ab0 100644 --- a/packages/vue3-lottie/src/vue3-lottie.vue +++ b/packages/vue3-lottie/src/vue3-lottie.vue @@ -112,9 +112,9 @@ export default defineComponent({ }, setup(props, { emit: emits }) { - const animationData = ref() const lottieAnimationContainer = ref() + let animationData: any let lottieAnimation: AnimationItem | null = null let direction: AnimationDirection = 1 @@ -131,14 +131,14 @@ export default defineComponent({ const responseJSON = await response.json() - animationData.value = responseJSON + animationData = responseJSON } catch (error) { console.error(error) return } } else if (isEqual(props.animationData, {}) === false) { // clone the animationData to prevent it from being mutated - animationData.value = cloneDeep(props.animationData) + animationData = cloneDeep(props.animationData) } else { throw new Error( 'You must provide either animationLink or animationData', @@ -153,7 +153,7 @@ export default defineComponent({ if (!lottieAnimationContainer.value) return // check if the animationData has been loaded - if (!animationData.value) return + if (!animationData) return // destroy the animation if it already exists lottieAnimation?.destroy() @@ -187,7 +187,7 @@ export default defineComponent({ renderer: props.renderer, loop: loop, autoplay: autoPlay, - animationData: animationData.value, + animationData: animationData, assetsPath: props.assetsPath, }