如何在Vue.js中調整大小時立即獲取元素寬度和高度? 這是我的代碼筆插圖 請幫我改變它,直到工作,謝謝!如何在Vue.js中調整大小時立即獲取元素寬度和高度
let app = new Vue({
el: '#app',
data: {
boxs: [{
width: 100,
height: 100
},
{
width: 100,
height: 100
}
]
}
});
#app {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.resize {
display: flex;
justify-content: center;
align-items: center;
margin: 5px;
width: 100px;
height: 100px;
overflow: hidden;
resize: both;
background-color: #C3E2CE;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.4/vue.js"></script>
<div id="app">
<div v-for="box,key in boxs" class="resize">
{{ box.width }} x {{ box.height }}
</div>
</div>