收藏
回答

针对 animate 动画中 keyframes 中参数不能使用变量么?

Page({
  data: {
    commentHeight300,
    showDetailfalse
  },
  onLoadfunction () {
    const { windowHeight } =  wx.getWindowInfo()
    const query = wx.createSelectorQuery()
    query.select('.navbar').boundingClientRect()
    query.select('#video-player').boundingClientRect()
    query.exec(([ nav, video ]) => {
      this.setData({
        commentHeight`${windowHeight - nav.height - video.height}`
      })
    })
  },
  showAnimfunction() {
    console.log(this.data.commentHeight) // 输出正常
    this.animate('.block', [
      { translateYthis.data.commentHeight },
      { translateY0 },
    ], 2400, () => {
      this.clearAnimation('.block')
    })
  },
  changefunction () {
    this.setData({
      showDetailtrue
    })
    wx.nextTick(() => {
      this.showAnim()
    })
  }
})
如此动画没效果,改成一个常量值 动画生效

最后一次编辑于  2024-12-19
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容