Vue中svga特效展示

 Vue中svga特效展示

这个url是线上地址,注意需要在vue.config.js里配置代理,不然会报跨域的错误。

附个文档链接↓

Package - svgaplayerweb

<template>
<div id="giftStyleAdd"></div>
</template>

<script>
created() {
    this.showSvg(url)
},
methods: {
//展示svga方法
    showSvg(url) {
      //一定要使用$nextTick,等到页面加载完成再处理数据
      this.$nextTick(() => {
        //这里动态给ID,列表
        this.player = new SVGA.Player("#giftStyleAdd");
        var parser = new SVGA.Parser("#giftStyleAdd");
        //这里使用动态加载的方式
        parser.load(url, (videoItem) => {
          this.widthDialog = String(videoItem.videoSize.width);
          this.player.setVideoItem(videoItem);
          this.player.startAnimation();
        });
      });
    },
}
</script>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值