Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uni微信小程序端type=“2d”在模拟器运行正常,真机失效 #170

Open
jinxinkai opened this issue Jun 28, 2021 · 0 comments
Open

Comments

@jinxinkai
Copy link

bug描述
uni微信小程序端type=“2d”在模拟器运行正常,真机失效
复现过程

<template>
  <view class="matching animated fadeIn">
    <view class="matching__mask" />
    <canvas id="matching" canvas-id="matching" type="2d" />
  </view>
</template>

<script>
import lottie from 'lottie-miniapp'

export default {
  onReady() {
    this.createSelectorQuery()
      .select('#matching')
      .fields({ node: true, size: true })
      .exec(async res => {
        const canvas = res[0].node
        const context = canvas.getContext('2d')
        const dpr = wx.getSystemInfoSync().pixelRatio
        canvas.width = res[0].width * dpr
        canvas.height = res[0].height * dpr
        context.scale(dpr, dpr)
        lottie.loadAnimation({
          renderer: 'canvas', // 只支持canvas
          loop: true,
          autoplay: true,
          path: `https://echojin.coding.net/p/bd-public/d/bd-public/git/raw/master/lottie.json`,
          rendererSettings: {
            canvas,
            context,
            clearCanvas: true
          }
        })
      })
  }
}
</script>

<style scoped lang="scss" rel="stylesheet/scss">
.matching {
  @include dialog-base;
  z-index: 99999999;

  canvas {
    width: 750rpx;
    height: 750rpx;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>

截图
image

错误设备信息
"lottie-miniapp": "^1.9.1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant