[Vuejs]-VueJs Understanding v-model and v-on:click

0👍

This is not the proper way to update a table in VueJS. By manipulating the DOM directly, you perform changes to the site that Vue doesn’t track (and hence doesn’t know about), which breaks reactivity.

The proper way to do this would be to store your list in a Vuex-Store and perform the update in there. I recommend reading up on the topic using the excellent documentation provided here: https://vuex.vuejs.org/

0👍

I would pass the object of products to javascript, Laravel has a package for this https://github.com/laracasts/PHP-Vars-To-Js-Transformer by Jeffrey Way.

Edit: oh cancel that, it looked from your broken fiddle you were trying to do something different.

In your axios response handler just update a data property for products with the response data. Then loop that property in VUE, no PHP side loop required.

  <td v-for="product in products">
    <input v-model="product.id" type="text" :name="product.name">
  </td>

Leave a comment