title: Vue - using refs to focus an element target
body: <p>When span class="before-click" is clicked,<br>
  I want it hidden, and input class="after-click" show up instead.<br>
  And the showed up input tag must be on focused!<br>
  The problem is when I try to use $refs.afterClick to access that DOM and give it .focus(), an unexpected error shows that .focus() is not a function.<br>
  How to solve this issue?
  Thanks.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var myApp = new Vue({
    el: '#app',
    data: {
      onEdit: false,
      msg: 'Something in here',
    },
    methods: {
      switchAndFocus() {
        if(!this.onEdit) {
         this.onEdit = true;
         this.$refs.afterClick.focus();
        }
      },
    },
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.3/vue.min.js"&gt;&lt;/script&gt;
  &lt;div id="app"&gt;
    &lt;span class="before-click" @click="switchAndFocus()" v-show="!onEdit"&gt;{{msg}}&lt;/span&gt;
    &lt;input type="text" class="after-click" ref="afterClick" :value="msg" v-show="onEdit"&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>