首页 > 解决方案 > 如何在 angluar11 中使用 lottie-web?

问题描述

我从事一个有角度的项目。我需要在我的项目中添加动画图标。所以我将使用lottie-web。我已经安装了lottie-web。我遵循了本指南https://www.npmjs.com/package/lottie-web。但图标不显示。

我已将 lottie-web 导入我的 compenent.ts 文件并这样写。

import Lottie from 'lottie-web'; 

 ngOnInit(): void {


    Lottie.loadAnimation({
      container: document.getElementById('logo'),
      renderer: 'svg',
      loop:false,
      autoplay:true,
      path:'./home.json',
     
        
    });
}

在 .html 文件中我这样写

  <div class="logo">
     <div id="logo"></div>
   </div>

我从https://lordicon.com/下载 .json 文件。

我的问题是我的页面上没有显示图标。我如何在 angluar11 中使用 lottie-web?

标签: angulariconslottie

解决方案


推荐阅读