Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
First element always checked

I have a code, when you click on a new task, the first one is crossed out, I can’t understand why.

enter image description here

enter image description here

When you click on a new task, the first one is crossed out, and the one I click on should be

<template>
<h4>Today Tasks</h4>  
<div class="tasks">
<div 
      class="task"
      :class="{ completed: task.isCompleted }"
      v-for="task in tasks"
      :key="task._id"
      @click="completedHandler(task._id)"
   >

  <div 
        class="round"
        :class="{ 
        business: task.type === 'business', 
        personal: task.type === 'personal',
        }"
        
        ></div>

    <span>{{task.name}}</span>
  </div>
</div>
  <div class="add-task">
    <input type="text" placeholder="Название задачи" v-model="taskName" />
    <button @click="addTask">+</button>
  </div>
</template>

<script>
// import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  data(){
    return {
      taskName: "",
      tasks: [{
        _id: "wadawdawdwa",
        name: "Create to do app in Vue js",
        isCompleted: false,
        type: "personal",
      }
      ]
    }
  },
    methods:{
      completedHandler:function(taskid){
        const currentTask=this.tasks.find((t)=> t._id=taskid);
        currentTask.isCompleted = !currentTask.isCompleted;
    },

    addTask: function(){
      this.tasks.push({
        _id: Math.random().toString(36).substring(2, 7),
        name: this.taskName,
        isCompleted: false,
        type: "personal",
       });
    },
  },
};
</script>
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!