I have a method "aggiornaQuantity" in this component that i would use in my vue. How can i do? Obviously I did various tests without any success

Vue.component('todo-item', {
    props: ['todo'],
    template: '...',
    methods: 
   {
     aggiornaQuantity: function() 
      {
       return this.todo.quantity = this.value ;
      }
    }  

var app7 = new Vue
   (
      {
         el: '#app-7',
         data:
         {
            message: '${Message}',
            risultato: true,
            groceryList: [],
            product: '',
            selected: '',
         },
         methods:
         {
           .....
         }

1 Answers

0
Thammarith On Best Solutions

Edit: I'm not sure if you want to know how to use the function or why your function doesn't work (as commented above). If it's the former, here's the answer:


You have to call it in one of the lifecycle instances. Most of the time, we call it in mounted().

...
methods: {
  foo () {
    // do something
  },
},
mounted() {
  this.foo();
},
...