SlideShare a Scribd company logo
How to Build
ToDo App
with Vue 3 +
TypeScript
www.bacancytechnology.com
I always like to code with defining types
and maintaining strictness, and that’s why
TypeScript has fascinated me. Being a
JavaScript developer, you indeed have
encountered this error – Cannot read
property ‘x’ of undefined.
For getting rid of such an error, you should
either verify all the possible use-cases of the
error or give TypeScript a fair shot. I
preferred the latter one, and I’m super
satisfied and happy with my code quality
now.
That’s why when VueJS came up with
support for TypeScript, I made up my mind
for trying Vue 3 + TypeScript. Believe me;
the struggle was real and worth it! Vuejs
and TypeScript is a perfect combination- it
gives you flexibility of Javascript and
strictness of TypeScript. I referred to VueJs
official documentation and a few other
blogs/tutorials for the starters. As nothing
was available in one place, I had to juggle
between blogs to build a demo application.
That’s when, I decided to write a blog post
for helping fellow VueJS developers. Here
are the topics which I will cover in this Vue
3 + TypeScript.
Table of Index
1. Introduction
2. Goal
3. Installing VueJS
4. Steps to Build Todo App with Vue 3 +
TypeScript
5. Conclusion
Introduction
VueJS framework is undoubtedly one of the
best JS frameworks. Its progressive take on
the coding part helps developers to build
lightweight and excellent applications.
Unlike AngularJS, VueJS didn’t provide
prominent support for TypeScript in its
older versions. That’s why we have rarely
heard of Vue TypeScript. But, we can
quickly build large-scale front-end apps
with Vue 3 and TypeScript from scratch
with the help of Vue CLI. Still, there’s a
drawback for full-fledged application
development; one might need to install
different third-party packages for
decorators and features. Let’s see what’s the
goal of this blog post.
Goal
Here’s a step-by-step tutorial on how to
build a simple Todo application with Vue 3 +
TypeScript.
Link of the source code – Github
Repository.
We will build something like this –
Video URL:
https://www.bacancytechnology.com/blog/
wp-content/uploads/2021/03/Todo-
app.mp4?_=1
How to Install
Vuejs
Open your terminal and follow these steps
to install VueJS in your system if you are
new to VueJS.
npm install -g @vue/cli
Check the version-
vue --version
You will see the latest version installed in
your system as shown below-
In this blogpost we won’t going to discuss
regarding TypeScript Vue, Vue CLI with
typescript and Vue.js typescript
individually. This blogpost is written to
build Todo app, setting up Vue 3 using
TypeScript. Though you can check these
below-mentioned links for basic
understanding-
Vue 3 Complete Guide
Vue 3 Youtube Tutorial
For VueJS:
For TypeScript:
Up and Running with TypeScript
TypeScript Github Repository
TypeScript in 5 mins
Steps to build
Todo app with
Vue 3 +
TypeScript
Create a todo app using this command-
vue create todo-app
You will see something like this. Select
Manually select features
1. Create and Set up Project
Set up your todo-app with these
configurations-
cd todo-app
npm run serve
After running the above commands, hit the
localhost in your browser, and you’ll see
your VueJS application’s default view.
2. Run project
Let’s start coding of building to do app with
Vue 3 + TypeScript!
The below-mentioned image will be our
project structure –
SCSS – Handles design part.
Models – For managing the type of tasks in
the to-do app.
Router – Handles routing of the
components.
Store – Managing central state (Vuex)
Views – Consists of pages that will be
displayed. It will have two folders –
AddTask and Home. Each of them consists
of four files, as shown below:
Now I’ll take one module at a time
and start editing its files. You can
replace these with your files.
router/index.js
Routing enables applications to display
components on their respective URLs.
Here, ‘/ and /add_task’ will render Home
and AddTask component respectively. You
can visit here to learn more about Vue 3
Router and Vue 3 composition API the way
it works.
import { createRouter, createWebHistory,
RouteRecordRaw } from "vue-router";
import Home from
"@/views/Home/Home.vue";
import AddTask from
"@/views/AddTask/AddTask.vue";
const routes: Array = [
{
path: "/",
name: "Home",
component: Home
},
{
path: "/add_task",
name: "AddTask",
component: AddTask
}
];
const router = createRouter({
history:
createWebHistory(process.env.BASE_URL),
routes
});
export default router;
App.vue
Consists entire application which will
server-side render on “app” Node. You can
open your developer tools and check the
very first parent < div > – It will consist of
id=app.
<template>
<div id="app">
<router-view />
<div class="bottom_bar">
<div class="row expanded">
<div class="sm-4 columns text-center">
<router-link to="/">
<i class="fa fa-home" aria-
hidden="true"></i>
<span>Home</span>
</router-link>
</div>
<div class="sm-4 columns text-center">
<router-link to="/create_task">
<i class="fa fa-plus" aria-hidden="true"
/>
<span>Add Tasks</span>
</router-link>
</div>
</div>
</div>
</div>
</template>
<style lang="scss"
src="./assets/scss/app.scss"></style>4
main.ts
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
createApp(App)
.use(store)
.use(router)
.mount("#app");
Now, moving towards the Vue TypeScript
part. We will create two files – BaseModel.ts
and Task.ts for declaring the type of the
objects of each task.
BaseModel.ts
export class BaseModel {
constructor() {
this.createdAt = new Date();
this.updatedAt = new Date();
this.deletedAt = new Date();
}
createdAt: Date;
updatedAt: Date;
deletedAt: Date;
}
export default BaseModel;
Task.ts
import { BaseModel } from "./BaseModel";
export class Task extends BaseModel {
name: string;
completed: boolean;
constructor(name: string) {
super();
this.name = name;
this.completed = false;
}
}
export default Task;
We will import Task.ts in AddTask.ts to
define the type of the variable.
Moving towards pages – AddTask and
Home
AddTask Folder
AddTask.html
The .html covers the UI part for Adding
Task page.
<div class="create_task">
<div class="row">
<div class="small-12 text-center">
<h4>Add Tasks</h4>
</div>
</div>
<div class="row align-center">
<div class="small-12 medium-7 columns">
<div class="card">
<div class="card-section">
<div class="row expanded">
<div class="small-12 columns">
<Legend for="todoName">
<b>Add your next task-</b>
</Legend>
<input
id="todoName"
type="text"
v-model="taskName"
placeholder="Add your next task here"
@keyup.enter="addTask()"
>
</div>
</div>
<div class="row expanded">
<div class="small-12 columns text-right">
<button
@click="addTask()"
type="button"
class="button success btn-lg btn-
block">
Add
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
AddTask.scss
.create_task{
margin-top: 2rem;
h4{
font-family: 'Helvetica Neue', Helvetica, Arial, sans-
serif;
margin: 2rem 0;
}
.card{
background-color:#8080800d;
}
.card-section{
padding: 1.5rem;
Legend{
font-size: 20px;
}
input{
border-radius: 5px;
}
button{
border-radius: 5px;
font-size: 18px;
padding: 10px 20px;
}
}
}
AddTask.ts
import { defineComponent } from "vue";
import Task from "../../models/Task";
export default defineComponent({
name: "AddTask",
data() {
return {
taskName: ""
};
},
methods: {
addTask(): void {
if (this.taskName !== "") {
const newTask = new
Task(this.taskName);
this.$store.commit("setTask", newTask);
this.taskName = "";
this.$router.push("/");
}
}
}
});
AddTask.vue
It comprises all the three files. You can choose
not to separate code into different files and
rather write the code here in just one file. But,
this looks cleaner and neat, so I chose this.
<template src="./AddTask.html"></template>
<script lang="ts" src="./AddTask.ts"></script>
<style lang="scss" src="./AddTask.scss"
scoped></style>
Planning to create your own Vue component
library?
Hire Vue.js Experts from us to build large-
scale front-end apps leveraging custom
component libraries and Vuex store modules.
Build Now
Home Folder
The .html part covers the UI part for Home
page where we will display tasks in the list
and take further action.
<div class="home">
<div class="row">
<div class="small-12 text-center">
<h4>VueJS + TypeScript Todo
Application</h4>
</div>
</div>
<div class="row align-center">
<div class="small-12 medium-7 columns">
<table class="main-table">
<thead>
<tr>
<th>To-do List</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
Home.html
<transition-group name="fade"
mode="out-in" tag="tbody">
<tr v-for="task in tasks"
:key="task.name">
<td width="75%" v-text="task.name"
class="line" :class='{"text-line-through":
task.completed}'>
</td>
<td width="10%" class="text-right">
<i class="fa fa-check" aria-
hidden="true"
@click="setTaskComplete(task)"></i>
</td>
<td width="10%" class="text-right">
<i class="fa fa-times" aria-
hidden="true"
@click.prevent="deleteTask(task)"></i>
</td>
<td width="10%"></td>
</tr>
</transition-group>
</table>
</div>
</div>
</div>
.home{
margin-top: 2rem;
h4{
font-family: 'Helvetica Neue', Helvetica,
Arial, sans-serif;
margin: 2rem 0;
}
tbody{
background-color:#8080800d;
}
thead{
background-color: #0000002e;
}
th{
font-family: 'Helvetica Neue', Helvetica,
Arial, sans-serif;
color: #0b0a0a
}
}
Home.scss
Home.ts
import { defineComponent } from "vue";
import Task from "../../models/Task";
export default defineComponent({
name: "Home",
data() {
return {
tasks: [] as Task[]
};
},
methods: {
setTaskComplete(task: Task): void {
this.$store.commit("completeTask", task);
},
deleteTask(task: Task) {
this.$store.commit("deleteTask", task);
}
},
mounted() {
this.tasks = this.$store.state.tasks;
}
});
Home.vue
It comprises all the three files. You can choose
not to separate code into different files and
rather write the code here in just one file. But,
this looks cleaner and neat, so I chose this.
<template src="./Home.html"></template>
<script lang="ts" src="./Home.ts"></script>
<style lang="scss" src="./Home.scss" scoped>
</style>
Now, we will configure store
store/index.ts
Here in this file we will have a state initiated
with static data to be displayed, mutations for
altering the state. Mutations are nothing but
functions which are used to add, edit, and
delete the values.
import { createStore } from "vuex";
import Task from "../models/Task";
import { findIndex } from "lodash";
export default createStore({
state: {
tasks: [
{
name: "Demo for VueJS and TS",
createdAt: new Date(),
updatedAt: new Date(),
completed: false
},
{
name: "UI design",
createdAt: new Date(),
updatedAt: new Date(),
completed: false
}
] as Task[]
},
mutations: {
setTask: (state, task) =>
state.tasks.push(task),
deleteTask(state, task) {
let taskIndex = findIndex(state.tasks, task);
state.tasks.splice(taskIndex, ++taskIndex);
},
completeTask(state, task) {
const taskIndex = findIndex(state.tasks,
task);
state.tasks[taskIndex].completed = true;
}
},
actions: {},
modules: {}
});
app.scss
$fa-font-path: "../../../node_modules/font-
awesome-sass/assets/fonts/font-awesome/";
@import "../../../node_modules/font-
awesome-sass/assets/stylesheets/font-
awesome";
@import "~foundation-
sites/scss/foundation";
@import "settings";
@include foundation-flex-classes;
@include foundation-flex-grid;
@include foundation-everything(true);
body{
font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif;
color: #4d4d4d;
font-size: 18px;
line-height: 1.4em;
}
.text-line-through {
text-decoration: line-through;
}
.button {
margin: 0;
}
.bottom_bar {
background-color: #0000002e;
font-size: 1.5rem;
position: fixed;
width: 100%;
bottom: 0;
padding: 1.5rem;
a {
color: #0b0a0ab0;
&.router-link-exact-active {
color: #0b0a0a;
}
i{
margin-right: 10px
}
}
}
.fade-enter-active, .fade-leave-active {
transition: all .2s ease;
}
.fade-enter, .fade-leave-active {
opacity: 0;
So, this was all the files that had to be changed
for developing a To-do app with Vue 3 +
TypeScript. If you have followed all the steps
as mentioned above, then definitely your
small application would be running as
desired.
This was just for your starter of building web
apps with Vue 3 and TypeScript. This
combination of Vue 3 + TypeScript is a very
vast concept to explore and learn. You can
manage your project efficiently with Vue 3
using TypeScript. In case, you need any
guidance for building a VueJS application
using TypeScript then without further ado,
contact Bacancy Technology and hire VueJS
developer. Our skilled team will dedicatedly
work to meet your requirements and
expectations.
Conclusion
Thank You
www.bacancytechnology.com

More Related Content

What's hot

Web development ppt
Web development pptWeb development ppt
Web development ppt
KBK Business Solutions
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
MongoDB
 
ppt of web designing and development
ppt of web designing and developmentppt of web designing and development
ppt of web designing and development
47ishu
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
React native
React nativeReact native
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development Fundamentals
Mohammed Makhlouf
 
Web Programming Assignment
Web Programming AssignmentWeb Programming Assignment
Web Programming Assignment
Vijayananda Mohire
 
Apache CouchDB
Apache CouchDBApache CouchDB
Apache CouchDB
Trinh Phuc Tho
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
Arvind Devaraj
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
Dr. Awase Khirni Syed
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
Smile Gupta
 
cloud computing architecture.pptx
cloud computing architecture.pptxcloud computing architecture.pptx
cloud computing architecture.pptx
SourodeepChakraborty3
 
Dot Net 串接 SAP
Dot Net 串接 SAPDot Net 串接 SAP
Dot Net 串接 SAP
LearningTech
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
ArezooKmn
 
PHP
PHPPHP
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
NodeXperts
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Dineesha Suraweera
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
Lecture 7: Server side programming
Lecture 7: Server side programmingLecture 7: Server side programming
Lecture 7: Server side programming
Artificial Intelligence Institute at UofSC
 

What's hot (20)

Web development ppt
Web development pptWeb development ppt
Web development ppt
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
ppt of web designing and development
ppt of web designing and developmentppt of web designing and development
ppt of web designing and development
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
React native
React nativeReact native
React native
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development Fundamentals
 
Web Programming Assignment
Web Programming AssignmentWeb Programming Assignment
Web Programming Assignment
 
Apache CouchDB
Apache CouchDBApache CouchDB
Apache CouchDB
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
 
cloud computing architecture.pptx
cloud computing architecture.pptxcloud computing architecture.pptx
cloud computing architecture.pptx
 
Dot Net 串接 SAP
Dot Net 串接 SAPDot Net 串接 SAP
Dot Net 串接 SAP
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
PHP
PHPPHP
PHP
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
Lecture 7: Server side programming
Lecture 7: Server side programmingLecture 7: Server side programming
Lecture 7: Server side programming
 

Similar to How to Build ToDo App with Vue 3 + TypeScript

An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
TO THE NEW Pvt. Ltd.
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
Dalibor Gogic
 
How to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasuraHow to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasura
Katy Slemon
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
Violetta Villani
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
Commit University
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
David Gibbons
 
Meet VueJs
Meet VueJsMeet VueJs
Meet VueJs
Mathieu Breton
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
Vivian S. Zhang
 
Single Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APISingle Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST API
Tejaswini Deshpande
 
Vue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerVue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue router
Katy Slemon
 
Vanjs backbone-powerpoint
Vanjs backbone-powerpointVanjs backbone-powerpoint
Vanjs backbone-powerpoint
Michael Yagudaev
 
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
Gavin Pickin
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
Alfa Gama Omega
 
Nuxtjs cheat-sheet
Nuxtjs cheat-sheetNuxtjs cheat-sheet
Nuxtjs cheat-sheet
ValeriaCastillo71
 
How to optimize the performance of vue js large application structure
How to optimize the performance of vue js large application structure How to optimize the performance of vue js large application structure
How to optimize the performance of vue js large application structure
Katy Slemon
 
Front End Development for Back End Developers - Denver Startup Week 2017
Front End Development for Back End Developers - Denver Startup Week 2017Front End Development for Back End Developers - Denver Startup Week 2017
Front End Development for Back End Developers - Denver Startup Week 2017
Matt Raible
 
Meteor Day Talk
Meteor Day TalkMeteor Day Talk
Meteor Day Talk
Brandon Bechtel
 
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
Ortus Solutions, Corp
 
Vue.js part1
Vue.js part1Vue.js part1
Vue.js part1
욱래 김
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
William Leeper
 

Similar to How to Build ToDo App with Vue 3 + TypeScript (20)

An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
How to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasuraHow to build crud application using vue js, graphql, and hasura
How to build crud application using vue js, graphql, and hasura
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Meet VueJs
Meet VueJsMeet VueJs
Meet VueJs
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Single Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APISingle Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST API
 
Vue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerVue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue router
 
Vanjs backbone-powerpoint
Vanjs backbone-powerpointVanjs backbone-powerpoint
Vanjs backbone-powerpoint
 
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
Nuxtjs cheat-sheet
Nuxtjs cheat-sheetNuxtjs cheat-sheet
Nuxtjs cheat-sheet
 
How to optimize the performance of vue js large application structure
How to optimize the performance of vue js large application structure How to optimize the performance of vue js large application structure
How to optimize the performance of vue js large application structure
 
Front End Development for Back End Developers - Denver Startup Week 2017
Front End Development for Back End Developers - Denver Startup Week 2017Front End Development for Back End Developers - Denver Startup Week 2017
Front End Development for Back End Developers - Denver Startup Week 2017
 
Meteor Day Talk
Meteor Day TalkMeteor Day Talk
Meteor Day Talk
 
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
 
Vue.js part1
Vue.js part1Vue.js part1
Vue.js part1
 
Devise and Rails
Devise and RailsDevise and Rails
Devise and Rails
 

More from Katy Slemon

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
Katy Slemon
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
Katy Slemon
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
Katy Slemon
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
Katy Slemon
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
Katy Slemon
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
Katy Slemon
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
Katy Slemon
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
Katy Slemon
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Katy Slemon
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
Katy Slemon
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
Katy Slemon
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
Katy Slemon
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
Katy Slemon
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdf
Katy Slemon
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
Katy Slemon
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Katy Slemon
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
Katy Slemon
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
Katy Slemon
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
Katy Slemon
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
Katy Slemon
 

More from Katy Slemon (20)

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdf
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
 

Recently uploaded

Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 

Recently uploaded (20)

Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 

How to Build ToDo App with Vue 3 + TypeScript

  • 1. How to Build ToDo App with Vue 3 + TypeScript www.bacancytechnology.com
  • 2. I always like to code with defining types and maintaining strictness, and that’s why TypeScript has fascinated me. Being a JavaScript developer, you indeed have encountered this error – Cannot read property ‘x’ of undefined. For getting rid of such an error, you should either verify all the possible use-cases of the error or give TypeScript a fair shot. I preferred the latter one, and I’m super satisfied and happy with my code quality now.
  • 3. That’s why when VueJS came up with support for TypeScript, I made up my mind for trying Vue 3 + TypeScript. Believe me; the struggle was real and worth it! Vuejs and TypeScript is a perfect combination- it gives you flexibility of Javascript and strictness of TypeScript. I referred to VueJs official documentation and a few other blogs/tutorials for the starters. As nothing was available in one place, I had to juggle between blogs to build a demo application. That’s when, I decided to write a blog post for helping fellow VueJS developers. Here are the topics which I will cover in this Vue 3 + TypeScript.
  • 4. Table of Index 1. Introduction 2. Goal 3. Installing VueJS 4. Steps to Build Todo App with Vue 3 + TypeScript 5. Conclusion
  • 6. VueJS framework is undoubtedly one of the best JS frameworks. Its progressive take on the coding part helps developers to build lightweight and excellent applications. Unlike AngularJS, VueJS didn’t provide prominent support for TypeScript in its older versions. That’s why we have rarely heard of Vue TypeScript. But, we can quickly build large-scale front-end apps with Vue 3 and TypeScript from scratch with the help of Vue CLI. Still, there’s a drawback for full-fledged application development; one might need to install different third-party packages for decorators and features. Let’s see what’s the goal of this blog post.
  • 8. Here’s a step-by-step tutorial on how to build a simple Todo application with Vue 3 + TypeScript. Link of the source code – Github Repository. We will build something like this – Video URL: https://www.bacancytechnology.com/blog/ wp-content/uploads/2021/03/Todo- app.mp4?_=1
  • 10. Open your terminal and follow these steps to install VueJS in your system if you are new to VueJS. npm install -g @vue/cli Check the version- vue --version You will see the latest version installed in your system as shown below- In this blogpost we won’t going to discuss regarding TypeScript Vue, Vue CLI with typescript and Vue.js typescript individually. This blogpost is written to build Todo app, setting up Vue 3 using TypeScript. Though you can check these below-mentioned links for basic understanding-
  • 11. Vue 3 Complete Guide Vue 3 Youtube Tutorial For VueJS: For TypeScript: Up and Running with TypeScript TypeScript Github Repository TypeScript in 5 mins
  • 12. Steps to build Todo app with Vue 3 + TypeScript
  • 13. Create a todo app using this command- vue create todo-app You will see something like this. Select Manually select features 1. Create and Set up Project
  • 14. Set up your todo-app with these configurations- cd todo-app
  • 15. npm run serve After running the above commands, hit the localhost in your browser, and you’ll see your VueJS application’s default view. 2. Run project
  • 16. Let’s start coding of building to do app with Vue 3 + TypeScript! The below-mentioned image will be our project structure –
  • 17. SCSS – Handles design part. Models – For managing the type of tasks in the to-do app. Router – Handles routing of the components. Store – Managing central state (Vuex) Views – Consists of pages that will be displayed. It will have two folders – AddTask and Home. Each of them consists of four files, as shown below:
  • 18. Now I’ll take one module at a time and start editing its files. You can replace these with your files. router/index.js Routing enables applications to display components on their respective URLs. Here, ‘/ and /add_task’ will render Home and AddTask component respectively. You can visit here to learn more about Vue 3 Router and Vue 3 composition API the way it works.
  • 19. import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; import Home from "@/views/Home/Home.vue"; import AddTask from "@/views/AddTask/AddTask.vue"; const routes: Array = [ { path: "/", name: "Home", component: Home }, { path: "/add_task", name: "AddTask", component: AddTask } ]; const router = createRouter({ history:
  • 22. Consists entire application which will server-side render on “app” Node. You can open your developer tools and check the very first parent < div > – It will consist of id=app. <template> <div id="app"> <router-view /> <div class="bottom_bar"> <div class="row expanded"> <div class="sm-4 columns text-center"> <router-link to="/"> <i class="fa fa-home" aria- hidden="true"></i> <span>Home</span> </router-link> </div>
  • 23. <div class="sm-4 columns text-center"> <router-link to="/create_task"> <i class="fa fa-plus" aria-hidden="true" /> <span>Add Tasks</span> </router-link> </div> </div> </div> </div> </template> <style lang="scss" src="./assets/scss/app.scss"></style>4
  • 25. import { createApp } from "vue"; import App from "./App.vue"; import router from "./router"; import store from "./store"; createApp(App) .use(store) .use(router) .mount("#app"); Now, moving towards the Vue TypeScript part. We will create two files – BaseModel.ts and Task.ts for declaring the type of the objects of each task.
  • 27. export class BaseModel { constructor() { this.createdAt = new Date(); this.updatedAt = new Date(); this.deletedAt = new Date(); } createdAt: Date; updatedAt: Date; deletedAt: Date; } export default BaseModel;
  • 29. import { BaseModel } from "./BaseModel"; export class Task extends BaseModel { name: string; completed: boolean; constructor(name: string) { super(); this.name = name; this.completed = false; } } export default Task;
  • 30. We will import Task.ts in AddTask.ts to define the type of the variable. Moving towards pages – AddTask and Home
  • 32. AddTask.html The .html covers the UI part for Adding Task page. <div class="create_task"> <div class="row"> <div class="small-12 text-center"> <h4>Add Tasks</h4> </div> </div> <div class="row align-center"> <div class="small-12 medium-7 columns"> <div class="card"> <div class="card-section"> <div class="row expanded"> <div class="small-12 columns"> <Legend for="todoName"> <b>Add your next task-</b> </Legend> <input
  • 33. id="todoName" type="text" v-model="taskName" placeholder="Add your next task here" @keyup.enter="addTask()" > </div> </div> <div class="row expanded"> <div class="small-12 columns text-right"> <button @click="addTask()" type="button" class="button success btn-lg btn- block"> Add </button> </div> </div> </div> </div> </div> </div> </div>
  • 35. .create_task{ margin-top: 2rem; h4{ font-family: 'Helvetica Neue', Helvetica, Arial, sans- serif; margin: 2rem 0; } .card{ background-color:#8080800d; } .card-section{ padding: 1.5rem; Legend{ font-size: 20px; } input{ border-radius: 5px; } button{ border-radius: 5px; font-size: 18px; padding: 10px 20px; } } }
  • 37. import { defineComponent } from "vue"; import Task from "../../models/Task"; export default defineComponent({ name: "AddTask", data() { return { taskName: "" }; }, methods: { addTask(): void { if (this.taskName !== "") { const newTask = new Task(this.taskName); this.$store.commit("setTask", newTask); this.taskName = ""; this.$router.push("/"); } } } });
  • 39. It comprises all the three files. You can choose not to separate code into different files and rather write the code here in just one file. But, this looks cleaner and neat, so I chose this. <template src="./AddTask.html"></template> <script lang="ts" src="./AddTask.ts"></script> <style lang="scss" src="./AddTask.scss" scoped></style> Planning to create your own Vue component library? Hire Vue.js Experts from us to build large- scale front-end apps leveraging custom component libraries and Vuex store modules. Build Now
  • 41. The .html part covers the UI part for Home page where we will display tasks in the list and take further action. <div class="home"> <div class="row"> <div class="small-12 text-center"> <h4>VueJS + TypeScript Todo Application</h4> </div> </div> <div class="row align-center"> <div class="small-12 medium-7 columns"> <table class="main-table"> <thead> <tr> <th>To-do List</th> <th></th> <th></th> <th></th> </tr> </thead> Home.html
  • 42. <transition-group name="fade" mode="out-in" tag="tbody"> <tr v-for="task in tasks" :key="task.name"> <td width="75%" v-text="task.name" class="line" :class='{"text-line-through": task.completed}'> </td> <td width="10%" class="text-right"> <i class="fa fa-check" aria- hidden="true" @click="setTaskComplete(task)"></i> </td> <td width="10%" class="text-right"> <i class="fa fa-times" aria- hidden="true" @click.prevent="deleteTask(task)"></i> </td> <td width="10%"></td> </tr> </transition-group> </table> </div> </div> </div>
  • 43. .home{ margin-top: 2rem; h4{ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; margin: 2rem 0; } tbody{ background-color:#8080800d; } thead{ background-color: #0000002e; } th{ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #0b0a0a } } Home.scss
  • 45. import { defineComponent } from "vue"; import Task from "../../models/Task"; export default defineComponent({ name: "Home", data() { return { tasks: [] as Task[] }; }, methods: { setTaskComplete(task: Task): void { this.$store.commit("completeTask", task); }, deleteTask(task: Task) { this.$store.commit("deleteTask", task); } }, mounted() { this.tasks = this.$store.state.tasks; } });
  • 47. It comprises all the three files. You can choose not to separate code into different files and rather write the code here in just one file. But, this looks cleaner and neat, so I chose this. <template src="./Home.html"></template> <script lang="ts" src="./Home.ts"></script> <style lang="scss" src="./Home.scss" scoped> </style> Now, we will configure store
  • 49. Here in this file we will have a state initiated with static data to be displayed, mutations for altering the state. Mutations are nothing but functions which are used to add, edit, and delete the values. import { createStore } from "vuex"; import Task from "../models/Task"; import { findIndex } from "lodash"; export default createStore({ state: { tasks: [ { name: "Demo for VueJS and TS", createdAt: new Date(), updatedAt: new Date(), completed: false }, {
  • 50. name: "UI design", createdAt: new Date(), updatedAt: new Date(), completed: false } ] as Task[] }, mutations: { setTask: (state, task) => state.tasks.push(task), deleteTask(state, task) { let taskIndex = findIndex(state.tasks, task); state.tasks.splice(taskIndex, ++taskIndex); }, completeTask(state, task) { const taskIndex = findIndex(state.tasks, task); state.tasks[taskIndex].completed = true; } }, actions: {}, modules: {} });
  • 52. $fa-font-path: "../../../node_modules/font- awesome-sass/assets/fonts/font-awesome/"; @import "../../../node_modules/font- awesome-sass/assets/stylesheets/font- awesome"; @import "~foundation- sites/scss/foundation"; @import "settings"; @include foundation-flex-classes; @include foundation-flex-grid; @include foundation-everything(true); body{ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #4d4d4d; font-size: 18px; line-height: 1.4em; } .text-line-through { text-decoration: line-through; } .button { margin: 0;
  • 53. } .bottom_bar { background-color: #0000002e; font-size: 1.5rem; position: fixed; width: 100%; bottom: 0; padding: 1.5rem; a { color: #0b0a0ab0; &.router-link-exact-active { color: #0b0a0a; } i{ margin-right: 10px } } }
  • 54. .fade-enter-active, .fade-leave-active { transition: all .2s ease; } .fade-enter, .fade-leave-active { opacity: 0; So, this was all the files that had to be changed for developing a To-do app with Vue 3 + TypeScript. If you have followed all the steps as mentioned above, then definitely your small application would be running as desired.
  • 55. This was just for your starter of building web apps with Vue 3 and TypeScript. This combination of Vue 3 + TypeScript is a very vast concept to explore and learn. You can manage your project efficiently with Vue 3 using TypeScript. In case, you need any guidance for building a VueJS application using TypeScript then without further ado, contact Bacancy Technology and hire VueJS developer. Our skilled team will dedicatedly work to meet your requirements and expectations. Conclusion