今天说一下在vue中操作真实的DOM.
<template>
<div>
<div ref="box">
hello world
</div>
</div>
</template>
<script>
export default{
//通过mounted
mounted(){
let box = this.$refs.box; //通过refs来拿到元素
let style = window.getComputedStyle(box);
console.log(style) //300px
}
}
</script>
<style>
div{
width:300px;
height:300px;
background-color:red
}
</style>