时间:2022-07-08 10:28:54 | 栏目:vue | 点击:次
(1) html中:
<div class="videoMa" ref="videoMa" style="width:100%;height:100%;"> <div id="playWnd" class="playWnd" :style="{width:videoBox.width+ 'px',height:videoBox.height+ 'px'}"></div> </div>
(2) data中:
videoBox:{ width:800, height:500, }
(3)mounted中:
mounted() { this.videoBox.width=this.$refs.videoMa.offsetWidth; this.videoBox.height=this.$refs.videoMa.offsetHeight; }
凡是有-的style属性名都要变成驼峰式,比如font-size要变成fontSize
除了绑定值,其他的属性名的值要用引号括起来,比如backgroundColor:'#00a2ff'而不是 backgroundColor:#00a2ff
html :style="{ color: activeColor, fontSize: fontSize + 'px' }" html :style="{display:(activeName=='first'?'flex':'none')}"
html :style="[baseStyles, overridingStyles]" html :style="[{display:(activeName=='first'?'flex':'none')},{fontSize:'20px'}]"
html :style="{color:(index==0?conFontColor:'#ddd')}" html :style="[{color:(index==0?conFontColor:'#ddd')},{fontSize:'22px'}]"
html :style="{ display: ['-webkit-box', '-ms-flexbox', 'flex'] }"