Copy value from button

Hi.
I’m trying to copy de value from a button to the clipboard.
But im always copying the previous value. I’m new to vue, and i guess the problem is that im putting the input into a var ( let copyText = document.querySelector(’#inpudID’);), and there must be a better way in vue.

<div id="container">
        <input :type="cStype" :id="cSid" :value="code">
        <div>{{code}}</div>
  <button v-on:click="copyCode" value="1">1</button>
  <button v-on:click="copyCode" value="2">2</button>
  <button v-on:click="copyCode" value="3">3</button>
  <button v-on:click="copyCode" value="4">4</button>
</div>
new Vue({
    el: "#container",

    data: {
        code: '0',
        cSid: 'inpudID',
        cStype: 'hidden'
    },

    methods: {
        copyCode: function (e) {
          console.log(e.target.value);
            this.code = e.target.value;
            this.cStype = 'text';
            let copyText = document.querySelector('#inpudID');
            console.log(copyText);
            copyText.select();
            document.execCommand("copy");
            //this.cStype = 'hidden';
        },
    },
    
});

https://jsfiddle.net/rtotal/vdc3e0us/2/

Make the method async: https://jsfiddle.net/4oethbmq/

thank you!

Any idea why this work in 2.2.1, but doesn’t work in 2.6.12?

It should still work in any version of Vue, it’s just an async method.

Done with the latest version of Vue: