收藏
回答

动画的height,不能用百分比?

height动画,设置单位rpx、px、vh都没问题。

但是改成百分比的,就是瞬间变化,没有动画的渐变效果了。

求帮助这么回事?bug还是我用的有问题?


<view style='background-color: red;' animation="{{an}}">

    <view style='height:300rpx'></view>

</view>


const app = getApp()
Page({
  data: {
    an:{}
  },
  onShow: function () {
    let a = wx.createAnimation({
      duration: 200
    });
    let i=1;
    setInterval(()=>{
       
      //正常
      // this.setData({
      //   an: a.height(i%2==0?300:0).step().export()
      // });
 
      //无动画效果
      this.setData({
        an: a.height(i % 2 == 0 ? '100%' : 0).step().export()
      });
      i++;
    },500);
  },
})


回答关注问题邀请回答
收藏

1 个回答

  • 卢霄霄
    卢霄霄
    2018-12-29

    给他的父标签一个高度,如果这个根标签,就设个

    page{

        height:100%;

    }


    2018-12-29
    有用 1
    回复 1
    • 周永强
      周永强
      2018-12-29

      谢谢,是这个问题,改了就好了、

      2018-12-29
      回复
登录 后发表内容