Skip to main content

Vue js very simple Todo app for begineers

How to create a very simple and minimalist Todo app with Vue js ?

A todo app is a very important concept for programming newbies. It includes handling
of dynamic form, its data and array manipulation. This is the basis of any big dynamic
user interface. And its a often obvious task for the new Interns in almost any company. So below here is a very very simple Todo app, which just takes an input from user and stores each todo in an array. 

Click the js fiddle link below to see the demo :
JS fiddle : https://jsfiddle.net/gitamgadtaula/cbzfj9vn/14/

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="cart">
{{myText}} <br />
<input type="text" v-model="myText" value="" @onclick="add()" />
<button @click="add()">click</button>
<hr />
<span v-for="item in myArray">
{{item}} <button @click="deleteFunc(item)">remove</button>
<hr />
<br
/></span>
</div>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
new Vue({
el: ".cart",
data: {
items: 0,
myText: "",
myArray: [],
},
methods: {
add: function () {
this.myArray.push(this.myText);
console.log("added inside the array");
},
deleteFunc: function (id) {
console.log("remove function called");
this.myArray.splice(this.myArray.indexOf(id), 1); //removes 1 element of the given index
},
},
});
</script>

Comments

Popular posts from this blog

How to read nth line of a text file in C programming using file handling?

C program to read the nth line of a file.  This file handling C program illustrates how to read the nth content of a text file.  Suppose your text filename is "documents.txt" and you want to read only 9th line of that file. Here's a source code to do so. #include <stdio.h> int main () { FILE * file = fopen ( "documents.txt" , "r" ); char line [ 256 ]; int i = 0 ; while ( fgets ( line , sizeof ( line ), file )) { i ++; if ( i == 9 ) { printf ( "%s" , line ); } } fclose ( file ); return 0 ; } Similarly if you want to read only the 1st/2nd/3rd/4th/5th or any other line then just run variable i till your desired line.   For example if i  want to read the 10th line of the same file if ( i == 10 ) { printf ( "%s" , line ); }

How to connect php to mysql database? Simple html comment box tutorial.

First thing first. You will need a little bit knowledge of web programming. Simple HTML will work. Now here is a step by step procedure on how to connect php to mysql database using local server. Lets create a simple comment box. And I will teach you how to do this on both Mac or windows/Linux. Here is a list of Applications you need before doing some coding. A text editor ( I would recommend Sublime text ) A local server software ( MAMP for mac , Xampp for windows/linux) Now that you have downloaded your local server software, install it and start the servers. If you are on mac follow the screenshot to start up the servers. Bravo ! Your computer is now a server (local though). If you are on windows/Linux follow the similar procedure to start your servers.  Now lets get into some simple coding. Since we are going to make a simple comment box, lets create two files "comment.php"and "comment_post.php" inside htdocs folder. Note : Your def...