vue.js 'document.getElementById' shorthand vue.js 'document.getElementById' shorthand vue.js vue.js

vue.js 'document.getElementById' shorthand


Theres no shorthand way in vue 2.

Jeff's method seems already deprecated in vue 2.

Heres another way u can achieve your goal.

 var app = new Vue({    el:'#app',    methods: {            showMyDiv() {           console.log(this.$refs.myDiv);        }    }       });
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script><div id='app'>   <div id="myDiv" ref="myDiv"></div>   <button v-on:click="showMyDiv" >Show My Div</button></div>