title: vue component method change data by variable
body: <p>I want to change array data,change it in vue methods.</p>
  
  <p><a href="https://codepen.io/deded007/project/editor/AQyykN" rel="nofollow noreferrer">https://codepen.io/deded007/project/editor/AQyykN</a></p>
  
  <p>My question is how to change the data by using a variable like this</p>
  
  <pre><code>created() {
    var a=this.thisisarray;
    this.thisisarray=[10];
    console.log('a expected '+this.thisisarray+',but '+ a);
  }
  </code></pre>
  
  <p>It's ok to use <code>this.thisisarray</code> directly.But it's not working to change variable <code>a</code>.My variable is still looking at the old reference.I always get <code>a expected 10,but 9999</code>
  I want to create a global method and pass my variable <code>a</code> to change it.</p>
  
  <pre><code>Vue.component('page-head', {
    template: '#page-head',
    data() {
      return {
        thisisarray:['a','b']
      };
    },
    created() {
  
        var a=this.thisisarray;
        this.thisisarray=[10];
        console.log('a expected '+this.thisisarray+',but '+ a);
    }
  })
  </code></pre>