Zeytinburnu masaj Talas masaj Tarsus masaj Tavşanlı masaj Terme masaj Tire masaj Torbalı masaj Toroslar masaj Turgutlu masaj Turgutreis masaj Turhal masaj Tuzla masaj Ulus masaj Ümraniye masaj Urla masaj Üsküdar masaj Vezirköprü masaj Viranşehir masaj Yatağan masaj Yenimahalle masaj Yenişehir masaj Yıldırım masaj Yomra masaj Yumurtalık masaj Yunusemre masaj Yüreğir masaj escort bayan İstanbul escort İzmir escort Kahramanmaraş escort Kastamonu escort Kayseri escort Kıbrıs escort Kırklareli escort Kocaeli escort Konya escort Kütahya escort Erbaa escort Erdemli escort Ereğli escort Erenler escort Ergene escort Esenler escort Esenyurt escort Eskil escort Espiye escort Eyüpsultan escort Eyyübiye escort Fatih escort Fatsa escort Fethiye escort Finike escort Gaziemir escort Gaziosmanpaşa escort Gazipaşa escort Gebze escort Gediz escort Gelibolu escort Gemerek escort Gemlik escort Geyve escort Gölcük escort Gönen escort Görükle escort Güllük escort Gümbet escort Gümüşlük escort Güngören escort Gürsu escort Haliliye escort Hendek escort Horasan escort Ilgın escort İlkadım escort İncirliova escort İnegöl escort İskenderun escort İzmit escort İznik escort Kadirli escort Kadıköy escort Kadınhanı escort Kağıthane escort Kahramankazan escort Kangal escort Kapaklı escort Karabağlar escort bursa escort bursa escort istanbul escort denizli escort düzce escort malatya escort erzincan escort zonguldak escort eskişehir escort gaziantep escort gaziantep escort gümüşhane escort hatay escort hatay escort ığdır escort gaziantep escort istanbul escort konya escort izmit escort kars escort escort adana escort bayan adıyaman escort bayan afyon escort bayan ağrı escort bayan aksaray escort bayan amasya escort bayan antalya escort bayan ankara escort bayan ardahan escort bayan artvin escort bayan aydın escort bayan balıkesir escort bayan bartın escort bayan batman escort bayan bayburt escort bayan bilecik escort bayan bingöl escort bayan bitlis escort bayan bolu escort bayan burdur escort bayan bursa escort bayan Çanakkale escort bayan Çankırı escort bayan Çorum escort bayan denizli escort bayan diyarbakır escort bayan düzce escort bayan edirne escort bayan elazığ escort bayan sivas escort bayan sinop escort bayan urfa escort samsun escort bayan sakarya escort bayan rize escort bayan osmaniye escort bayan ordu escort bayan niğde escort bayan nevşehir escort bayan muş escort bayan muğla escort bayan mersin escort bayan mardin escort bayan manisa escort bayan malatya escort bayan kütahya escort bayan konya escort bayan kocaeli escort bayan kırşehir escort bayan kırklareli escort bayan kırıkkale escort bayan kilis escort bayan kıbrıs escort bayan kayseri escort bayan kastamonu escort bayan kars escort bayan karaman escort bayan karabük escort bayan maraş escort izmit escort bayan izmir escort bayan istanbul escort bayan Isparta escort bayan Iğdır escort bayan hatay escort bayan hakkari escort bayan gümüşhane escort bayan giresun escort bayan gaziantep escort bayan eskişehir escort bayan erzurum escort bayan erzincan escort bayan tekirdağ escort bayan tokat escort bayan trabzon escort bayan uşak escort bayan van escort bayan yalova escort bayan yozgat escort bayan zonguldak escort bayan

windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

how can i send methods with props in vue js? i have 2 methods in components but one of them didnt work?

Asked By: Anonymous

hi friend i have a question.
i want create todo-list app with Vue an i have 3 components now:
task component is in tasks components is in app components (task is child of tasks and tasks in child of app)

i want handle delete this tasks and set reminder this tasks
i have a tasks array with some object in it that is pass from app.vue to tasks component
i have a property of reminder in objects of tasks that is have a boolean


i want delete task with handleDelete but this function has an error
but
when i write this function in app component it work!
and set reminder in tasks worked!

why handleDelete didn’t work in tasks component but setReminder worked in it?

my app components:

        <template>
      <div class="container">
        <Header title="write your task" />
        <Tasks :tasks="tasks" />
      </div>
    </template>
    
    <script>
    import Header from "./components/Header";
    import Tasks from "./components/Tasks";
    export default {
      name: "App",
      components: {
        Header,
        Tasks,
      },
      data() {
        return {
          tasks: [],
        };
      },
      methods: {
       
      },
      created() {
        this.tasks = [
          {
            id: 1,
            text: "do project",
            day: "march 3rd at 1pm",
            reminder: true,
          },
          {
            id: 2,
            text: "rest",
            day: "march 3rd at 1pm",
            reminder: false,
          },
          {
            id: 3,
            text: "sleep",
            day: "march 3rd at 1pm",
            reminder: true,
          },
          {
            id: 4,
            text: "running",
            day: "march 3rd at 1pm",
            reminder: true,
          },
          {
            id: 5,
            text: "do homework",
            day: "march 3rd at 1pm",
            reminder: true,
          },
          {
            id: 6,
            text: "go home",
            day: "january 3rd at 1pm",
            reminder: false,
          },
        ];
      },
    };
    </script>

my tasks component is:

<template>
  <div v-for="task in tasks" :key="task.id">
    <Task :task="task" :tasks="tasks" 
    @DeleteTask="handleDeleteTask" 
    @toggle-reminder ="setReminder"
    />
  </div>
</template>

<script>
import Task from "./Task";

export default {
  name: "Tasks",
  props: {
    tasks: Array,
  },
  components: {
    Task,
  },
  methods: {
 handleDeleteTask(id) {
      console.log(this.tasks);
      this.tasks = this.tasks.filter((i) => i.id !== id);
      console.log(this.tasks);
    },
    setReminder(id) {
      const index = this.tasks.findIndex((task) => task.id === id);
      console.log(this.tasks[index].reminder);
      this.tasks[index].reminder = !this.tasks[index].reminder;
      console.log(this.tasks[index].reminder);
    },
  },
};
</script>

an task component is :

<template>
  <div
    :class="[task.reminder ? 'reminder' : '', 'task']"
    @dblclick="$emit('toggle-reminder' , task.id)"
  >
    <h3>
      {{ task.text }}
      <i class="fas fa-times" @click="this.$emit('DeleteTask', id);"></i>
    </h3>
    <p>{{ task.day }}</p>
  </div>
</template>

<script>
export default {
  name: "Task",
  props: {
    task: Object,
    tasks: Array,
  },


};
</script>

Solution

Answered By: Anonymous

task.id

here you are passing id directly tho it should be task.id

//From
<i class="fas fa-times" @click="this.$emit('DeleteTask', id);"></i>
//To
<i class="fas fa-times" @click="this.$emit('DeleteTask', task.id);"></i>

no prop mutation

you shouldnt change prop values , any variable passed by prop shouldnt be modified , its an image of the original variable in the parent compopent , you should set up new emits in you tasks.vue -> app.vue the same way you did with task.vue -> tasks.vue

check this working sandbox

naming convention

the browser will get confused about @DeleteTask (event listener in you tasks component ) and wont link it to the event since its the sae as @deletetask for him

you already named the other one in kebab-case thats why its working

change
@click="this.$emit('DeleteTask', id);"
To @click="this.$emit('delete-task', id);"

and
@DeleteTask
To @delete-task;

Naming conventions from the Vue docs say to always name events with
kebab-case. The reason for this is that when Vue compiles its HTML,
HTML does not differentiate between upper or lowercase letters

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort http://www.kadinescort.net Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort