数组操作
增加元素(保持响应式)
方法1:通过Vue.set()
const list = [1,2]
// 添加一个元素到索引 3处
// 等价于list[2] = 3
Vue.set(list, 2, 3)
// or
vm.$set(list, 2, 3)
方法2:通过Array.splice()
const list = [1,2]
// splice(indexOfItem, setp, newValue)
this.list.splice(2, 1, 3)
方法1:通过Vue.set()
const list = [1,2]
// 添加一个元素到索引 3处
// 等价于list[2] = 3
Vue.set(list, 2, 3)
// or
vm.$set(list, 2, 3)
方法2:通过Array.splice()
const list = [1,2]
// splice(indexOfItem, setp, newValue)
this.list.splice(2, 1, 3)