When i push a value in my array with VueJS, chrome display it but just after my web page is reloading.
let vm = new Vue ({
el:'#app2',
data: {
people: ['Robert', 'Pablo', 'Lucas', 'Teban']
},
methods: {
addPerson: function() {
this.people.push('Maxime')
},
}
})
<section id="app2" style="margin-top: 100px">
<p>{{people}}</p>
<form>
<button v-on:click='addPerson'>Ajouter une personne</button>
</form>
</section>
addPerson()
is not reloading the page? E.g. it is a<button>
or an<a>
element and you didn't useevent.preventDefault()
(or settype="button"
for the former?