1๐
โ
<template>
<layout
v-for="(value, idx) in array"
:pickUpLength="array.length"
:idx="idx"
:key="idx"
>
<button @click="addArray">add</add>
</template>
<script>
export default {
data() {
array:[
{"date" : "", "time": ""},
{"date" : "", "time": ""}
]
},
methods:{
addArray(newVal){
// This is what you are doing. You can't "watch" arrays or Objects in Vue.js v2.x.x (changing in v3.x.x).
// this.array.splice(this.array.length - 1, 0, {"yes":"no"})
// This is what you have to do in this situation (based upon your comments from my original answer):
this.array = this.array.slice(0, this.array.length - 1).concat(newVal, this.array[this.array.length - 1]);
}
}
};
</script>
๐คth3n3wguy
Source:stackexchange.com