这样获取的数据是错误的!
<body>
<div class="container">
<div class="img-box" ref="box">
<img :src="url">
</div>
</div>
<script type="text/javascript">
var vm = new Vue({
el: '.container',
data: {
url: 'img/logo.png'
},
methods: {
getHeight () {
let dom = this.$refs.box;
console.log('1:' + dom.offsetHeight) // 21 or 22
}
},
mounted () {
this.getHeight();
}
});
Vue.nextTick(function(){
console.log('2:' + vm.$refs.box.offsetHeight) // 21 or 22
})
</script>
</body>
请问有没有办法获取???
小生方勤
相关分类