I am looking for assistance constructing a task management application using vue.js

I am facing an issue with developing a to-do list using Vue.js.

  • The goal is to add tasks to the list by entering them and clicking a button.

  • Once added, the new task should show up under "All Tasks" and "Not finished".

  • Buttons for marking tasks as "done" or "not done" are provided for both categories.

  • If a task is marked as done, it should be moved from "All Tasks" to "finished".

  • Tasks not marked as finished should remain in the "Not finished" section with only a "done" button available.

This is what I have been able to accomplish so far. I need help figuring out how to make this to-do list fully functional.

<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="lib/js/vue.js"></script>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="todoapp">
      <h1>TO-DO</h1>
      <p>
        <label for="newtask">Add New Task</label>
        <input id="newtask" type="text" v-model="newtasks" />
        <button class="hinzu" v-on:click="newtask">Add</button>
      </p>

      <h1>All Tasks</h1>

      <ul>
        <li v-for="task in tasks">
          {{aufgabe}}<br /><button class="Task not done!">Not Done!</button
          ><button class="Task done!">Done!</button>
        </li>
      </ul>

      <h2>Not Finished</h2>
      <ul>
        <li v-for="task in tasks">
          {{aufgabe}}<br /><button class="Task not done!">Not Done</button
          ><button class="Task done!" v-on:click="done">Done!</button>
        </li>
      </ul>

      <h2>Finished</h2>
      <ul></ul>
    </div>

    <script>
      var app = new Vue({
        el: "#todoapp",
        data() {
          return {
            tasks: [],
          };
        },
        methods: {
          newtask() {
            this.tasks.push(this.newtasks);
          },
          
          done() {
            this.tasks.pop(this.newtasks);
          },
        },
      });
    </script>
  </body>
</html>

Answer №1

I have identified the following issues:

   <input id="newtask" type="text" v-model="newtasks" />

The newtasks data property is not defined and should be included in the data().

You are using the variable task in the iterator but attempting to display {{aufgabe}}, which is not defined.

<li v-for="task in tasks">
    {{aufgabe}}<br /><button class="Task not done!">not done</button>
    <button class="Task done!" v-on:click="done">done!</button>
</li>

Check out the code below for a playground with the corrected version.

var app = new Vue({
  el: "#todoapp",
  data() {
    return {
      tasks: [],
      newtasks: null
    };
  },
  methods: {
    newtask() {
      this.tasks.push(this.newtasks);
    },

done() {
  this.tasks.pop(this.newtasks);
},
},
});
 <div id="todoapp">
  <h1>TO-DO</h1>
  <p>
    <label for="newtask">Add new Task</label>
    <input id="newtask" type="text" v-model="newtasks" />
    <button class="hinzu" v-on:click="newtask">Add</button>
  </p>

  <h1>All Tasks</h1>

  <ul>
    <li v-for="task in tasks">
      {{task}}<br /><button class="Task not done!">not done!</button
      ><button class="Task done!">done!</button>
    </li>
  </ul>

  <h2>Not finished</h2>
  <ul>
    <li v-for="task in tasks">
      {{task}}<br /><button class="Task not done!">not done</button
      ><button class="Task done!" v-on:click="done">done!</button>
    </li>
  </ul>

  <h2>finished</h2>
  <ul></ul>
</div>
<script src="https://unpkg.com/vue@2"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The response contains a JSON object with the values [object, Object]

I am attempting to showcase JSON data in an HTML table. Here is the code I have been using: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ ...

PHP script to populate a table with images based on certain conditions

I have a table in HTML that displays results from a SQL database on the right hand side. The code snippet for populating each cell is as shown below: <tr> <td>House</td> <td><?php echo $row_buyerdetails['tod_hous ...

Having trouble viewing the image slider on an HTML webpage

I've been attempting to incorporate an image slider into my personal website on GitHub, but I've encountered some difficulties as the images are not displaying. Interestingly, I can load individual images without using the slider and they show up ...

I've been attempting to relocate a CSS element at my command using a button, but my previous attempts using offset and onclick were unsuccessful

I am trying to dynamically move CSS items based on user input or button clicks. Specifically, I want to increment the position of elements by a specified number of pixels or a percentage of pixels. Currently, I am able to set the starting positions (top a ...

After the form is successfully submitted, you can remove the required attribute

Upon clicking the submit button of a form, an input box is highlighted with a red border if empty. After successful jQuery AJAX form submission, a message "data submitted" is displayed and the form is reset causing all input fields to be highlighted in red ...

Is there a way to implement pagination for data in Laravel and Vue.js?

Currently, I am in the process of creating a website using Laravel and Vue.js. My approach involves using a complex Eloquent query to retrieve data from the database, shown below: $query->with([ 'deviceAssignment.deviceSetting.sim', ...

Preventing users from entering past dates in Angular 6 - A step-by-step guide

Here is my current code snippet: ngOnInit() { let now = new Date(); this.date = formatDate(now, "dd/mm/yyyy",'en-US'); console.log("dateFormat :",this.date); } This is the html part of my code: <input type="date" [min]={{da ...

Encountering the error message "Unable to access property 'addEventListener' of null while trying to manipulate innerHTML"

Currently, I am utilizing innerHTML to include certain elements and a wrapper around them. for (i = 0; i < arr.length; i++) { b.innerHTML += "<div class='wrapper'><div class='col-4'>" + arr[i].storeID + "</div> ...

Encountering a problem with the divLogoBlock element in the code snippet below

I am experiencing an issue with the code below. The divLogoBlock does not appear when I copy and paste the entire page into Outlook as a signature. I believe there may be a problem with the CSS. Can someone please assist me? <html lang="en"><he ...

Unusual performance issues observed in a flexbox when adjusting window size in mobile Chrome

Encountering an unusual issue with flexbox on a mobile browser. For a visual demonstration, view this gif Specifically happening on Chrome mobile on a Google Pixel phone. Using a resize script to adjust element sizes due to limitations with 100vh: windo ...

How to utilize variables and axios in the mounted lifecycle hook of Vue.JS?

I want to implement an overlay that displays data fetched by axios when the overlay is loaded. I attempted it this way, but encountered an issue where I can't use a variable (.get("/edit/" + id) but it works with a hardcoded value (.get("/edit/" + "12 ...

My Angular Router is creating duplicate instances of my route components

I have captured screenshots of the application: https://ibb.co/NmnSPNr and https://ibb.co/C0nwG4D info.component.ts / The Info component is a child component of the Item component, displayed when a specific link is routed to. export class InfoComponent imp ...

In this guide, learn the best way to dynamically adjust image height to match the height of any device

I am trying to make sure that the image on the front page of my website fits the height of the screen or device, and resizes responsively without cropping when the device height changes. How can I achieve this? If you need a visual example of what I mean, ...

What is the best way to display two arrays next to each other in an Angular template?

bolded text I am struggling to display two arrays side by side in an angular template. I attempted to use ngFor inside a div and span but the result was not as expected. A=[1,2,3,4] B=[A,B,C,D] Current Outcome using ngFor with div and span : Using Div : ...

Struggling to transfer information from Blade to Vue in Laravel 5.3?

I'm currently working on integrating Vue components into Laravel 5.3 and I'm facing an issue with passing data from my blade template to a Vue component. Despite trying several solutions, I haven't been able to resolve the error I'm en ...

Is there a way to ensure that text is always displayed at the bottom of an image, perfectly aligned with the left edge of the image, regardless of the parent alignment?

I'm working on creating a layout in HTML/CSS/Bootstrap with an image and text below it. The challenge is to ensure that the text always starts at the left border of the image, regardless of its length. Here's what I need the layout to look like: ...

Encountering a 404 Error in CKFinder 3 integration with Laravel 6 and Vuejs while accessing the File Browser

My progress so far includes almost being able to successfully upload files to my Laravel installation using CKEditor and the CKFinder file browser opening from the route myurl/ckfinder/browser. However, I have encountered an issue where clicking on the ima ...

Issues with CSS hovering effects

this is my unique code snippet CSS Stylesheet .Navigation-signIn { background-color: #c8db5a; } .Navigation-signIn։hover { background-color: #ffffff; } JSX Component import { NavLink } from "react-router-dom"; import { BrowserRouter } fro ...

The build process encounters an issue with initializing Sentry's Vuejs (with Typescript) Integration

While attempting to build my (vue-cli-3 based) Vuejs project using gitlab-runner on my local machine, an error occurs: 98% after emitting CopyPlugin ERROR Failed to compile with 1 errors ... Property 'util' is missing in type 'VueConstruct ...

What are the steps for implementing CSS in Markdown?

How can I incorporate a CSS class into a Markdown file? For example, using <i class="icon-renren"></i> (from the fontawesome library) should display an icon when its CSS file is imported in HTML. Is there a way to achieve this in Markdown? ...