screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <h3>Vue Get Element Height and Width</h3> <div id="app"> <div ref="myElement" class="square"> </div> <p>Height of Element: {{height}}px</p> <p>Width of Element: {{width}}px</p> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { height: '', width: '' } }, mounted() { const element = this.$refs.myElement this.width = element.offsetWidth this.height = element.offsetHeight } }); </script> </body> <style scoped> .square{ background-color: brown; width:240px; height:248px } </style> </html>