<video bindloadedmetadata="getProportion"  
 style="width:100%;height:  {{proportion * 100 +'%'}};"
 show-fullscreen-btn='{{false}}' 
 show-play-btn='{{false}}' 
 show-bottom-progress='{{false}}' 
 controls='{{false}}' 
 muted='{{true}}'  
 loop autoplay src="{{item.src}}"/>

 bindloadedmetadata:视频元素加载完成时触发。

getProportion (e) {
        var that = this;
        var height = e.detail.height;
            
         //视频的宽
         var width = e.detail.width;

         //算出视频的比例
          var proportion = height / width  ;

         that.setData({
            proportion
         });
  },

Logo

一站式 AI 云服务平台

更多推荐