<div id="app">
  {{ arr }}
  <button @click="len">點我</button>
  <button @click="len">增加</button>
</div>
var vm = new Vue({
  el: '#app',
  data:{
    arr: [1, 2, 3]
  },
  methods: {
    len() {
      this.arr.length = '2'
      console.log(this);
    },
    add() {
      this.arr[4] = 4;
      console.log(this);
    }
  }
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js