Skip to content

Commit

Permalink
fix(lottie): 重复加载动画的时候会导致页面卡死
Browse files Browse the repository at this point in the history
  • Loading branch information
X3ZvaWQ committed Nov 6, 2024
1 parent 38818f0 commit 30635e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/lottie_mark.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<script>
import lottie from "lottie-web";
import { cloneDeep } from "lodash";
const animations = require.context("../assets/lottie", false, /\.json$/);

export default {
Expand All @@ -27,12 +28,14 @@ export default {
},
methods: {
loadAnimation() {
const data = cloneDeep(animations(`./${this.mark}.json`));
const ref = this.$refs.lottieContainer;
lottie.loadAnimation({
container: this.$refs.lottieContainer,
container: ref,
renderer: "svg",
loop: true,
autoplay: true,
animationData: animations(`./${this.mark}.json`),
animationData: data,
});
},
},
Expand Down

0 comments on commit 30635e6

Please sign in to comment.