vue中style样式动态绑定

方法一:

(1) html中:

 
  1. <div class="videoMa" ref="videoMa" style="width:100%;height:100%;">

  2. <div id="playWnd" class="playWnd" :style="{width:videoBox.width+ 'px',height:videoBox.height+ 'px'}"></div>

  3. </div>

(2) data中:

 
  1. videoBox:{

  2. width:800,

  3. height:500,

  4. }

(3)mounted中:

 
  1. mounted() {

  2. this.videoBox.width=this.$refs.videoMa.offsetWidth;

  3. this.videoBox.height=this.$refs.videoMa.offsetHeight;

  4. }

猜你喜欢

转载自blog.csdn.net/hsany330/article/details/111360597