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

Switch a div to a computed location

I'm having trouble getting this code to animate a div to a calculated position. Can someone please help me troubleshoot? $(document).ready(function() { var is_Clicked = false; $("#togglebutton").click(function() { if (is_Cli ...

Next JS Event Listener Failing to Detect Scroll Events

Currently, I am attempting to change the state and display a shadow in the navigation bar when the user scrolls, but for some reason it is not detecting the event. I am working with nextJS 13 and tailwind css. const [shadow, setShadow] = useState(false) ...

The application of CSS rule shadowing is not consistently enforced

Why does the text in the selected element not appear yellow like the "char_t" link above, even though they have the same class? It seems like it should be yellow based on the inspector, but it's not displaying as such on the actual page. This issue is ...

Merging the Select and Input elements side by side using Bootstrap grid system

Is there a way to combine all form group items like Select and Input using only the bootstrap framework? I attempted the method below, but there is an extra space between the Select and Input Box. Check out the DEMO ...

I seem to be having a problem with CSS and Flexbox sizing. Does anyone have an explanation for what might be

Hey there! I'm currently in the process of building a Netflix clone, and everything seems to be working well except for one issue with the layout. No matter how I adjust the width of the div containing the images, they just won't change size. I&a ...

Ensure that all links are opened in a new tab

When including _blank in the a href URL, my website contains various elements like iframes and ads from Adsense, Taboola,, etc. Currently, when a user clicks on an iframe or ad, it opens in the same window. Is there a way to ensure that all URLs (includin ...

Creating two distinct SVG images without interfering with other div elements can be accomplished by properly structuring the HTML

I am working on a page layout that consists of three main sections. There is a top bar with buttons, a middle section that needs to load different pages using jQuery, and a bottom bar with additional buttons. On top of all this are floating windows that op ...

Addressing some minor visual inconsistencies in an HTML bullet-pointed list

After reviewing my current code, it is displaying the following: https://i.stack.imgur.com/dvjrc.jpg I am attempting to make the following changes: Ensuring each line in the list fits properly within its corresponding box by utilizing vertical-align: to ...

What is the best way to convert this html code into php?

I’m trying to figure out how to incorporate all of this into my loop, but I’m not sure if it can be broken up. However, PHP needs to interpret it as HTML. $movieDetails = <header class="masthead" role="banner"> <div class="logo-con ...

Help needed with using Regex to restrict the number of alphabetical characters allowed

Struggling with configuring RegEx's. Seeking guidance to create a RegEx with the following criteria: Only allow numbers (0-9) Allow a period (.), negative sign (-), plus sign (+), dollar sign ($), and comma (,) Do not permit any alphabetic characte ...

Adjust grid percentages using jQuery Mobile

Struggling with creating a grid that includes form drop-downs and text boxes. Desiring the grid to be divided into sections of 25%, 50%, 25%, but having trouble understanding the grid system syntax. <fieldset class="ui-grid-b"> <div clas ...

Using the linear-gradient method in CSS for border images

I managed to successfully create a design using the CSS properties border-image and linear-gradient. However, I am struggling to understand the syntax involved. While I grasp the concept that the series of colors defines the gradient transition, as well as ...

This webpage is optimized for all browsers, with the exception of the Android Browser that may display fonts with larger sizes

When developing my webpage, I made sure it was compatible with all major browsers and even optimized it for mobile browsers. However, I overlooked testing the page on Android browser (specifically Android 4.2) and encountered some issues. The viewport set ...

Exploring the attributes of div elements with XPath

Currently, I am in the process of familiarizing myself with xpath through the creation of a basic program that will display the list of Premier League fixtures in football from a specific webpage. The page in question can be found at the following link: A ...

Problem with fetching Grails

I have a table nested within an anchor tag. The table is centered on the page, with each row containing an image. When the page loads, I noticed the following: a) The table initially appears at the top-left corner of the screen. b) As there are multiple v ...

What is the best way to integrate an admin template into a website without relying on popular CMS platforms like WordPress?

Do I need to use a WordPress system in the backend in order to utilize an admin template? I've noticed that there are several sleek web admin templates available in Bootstrap. I'm interested in using one of them but unsure how to do so without re ...

The navigation bar vanishes from sight while scrolling underneath other sections

UPDATE: Problem solved! I discovered that the 'overflow:hidden' inside the #main for the media query was causing the navigation to disappear. I have a scroll navigation positioned at the top of my webpage. However, as I scroll down, the navigati ...

What could be causing the issue with axios when trying to send a PUT request for a Laravel API call?

Need help with my Vue component request: submit() { axios .put(`/api/posts/${this.slug}`, this.fields, { headers: { "content-type": "multipart/form-data" }, }) .then((res) => { // s ...

Positioning the label for a Material-UI text field with an icon adornment when the shrink property is set

https://i.stack.imgur.com/E85yj.png Utilizing Material-UI's TextField, I have an Icon embedded within. The issue arises when the label "Your good name here" overlaps the icon instead of being placed beside it. This problem emerged after I included ...

What is the best way to align an inline list in the center so that it is responsive across all

Here is the CSS code provided: .wrapper{ display: inline; line-height: 2em; width: 100%; height: 100%; min-width: 1000px; min-height: 1000px; text-align: center; } ul{ list-style: none; } li{ list-style: none; } .craftb ...