V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
CSGO
V2EX  ›  问与答

谁知道 lottie,为何我用在 web 上一直显示不出来?

  •  
  •   CSGO · 2018-08-02 14:29:01 +08:00 · 1859 次点击
    这是一个创建于 2087 天前的主题,其中的信息可能已经有所发展或是发生改变。

    指南: http://airbnb.io/lottie/web/web.html

    我添加了

    <script src="js/bodymovin.js" type="text/javascript"></script>

    把 data.json 放到根目录,bodymovin.js 放在了根目录的 js 文件夹里,然后 js 文件夹里建立 index.js, 然后复制了指南的代码进去,修改了 id 名字,可是一直不显示啊!

    project: https://pan.baidu.com/s/1dDf_wqx82tBY-06mRMvQIA

    2 条回复    2018-08-03 09:02:13 +08:00
    DeepCold
        1
    DeepCold  
       2018-08-02 15:39:54 +08:00
    path: 'data.json', // 这个相对路径没填对,想万无一失可以用网络地址
    renderer: 'svg/canvas/html', // 这个选一个就好,官网示例用的 svg,我用的 canvas 都 OK
    CSGO
        2
    CSGO  
    OP
       2018-08-03 09:02:13 +08:00 via Android
    @DeepCold 看一下作者给我的回复:

    Hi, your folder is named "_js" and the html is looking for a folder called "js".
    Second, in the index you're passing a variable element as the container of the animation but you haven't specified what is the value of that variable. It should point to an element in the DOM.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2878 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 03:53 · PVG 11:53 · LAX 20:53 · JFK 23:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.