I have recently been delving into vue.js for my work and encountered a significant issue.
I wanted to create a simple TODO application. In my index.html file, I only have a div for a header and a root div with an ID: #app
.
Inside the root div, there is another div (with the class .todobox
) where I am displaying a list of tasks using v-for
. In my main.js file, when I reference the #app
and input an array of tasks, the console does not display any major errors. Each task also includes a description (variant.varDesc
), which is placed within a <p>
element in the todobox
.
Issue: Upon opening the application, it only displays one empty .todobox with a <p>
element containing the text: {{variant.varDesc}}
.
Can anyone offer assistance with this? Any help would be greatly appreciated! Thank you in advance!
var todo = new Vue({
el: '#app',
data: {
styledone: {
'background-color': crimson,
},
styleundone: {
'text-decoration': line-through,
'background-color': gray
},
variants: [
{
varID: 2333,
varDesc: 'Create a new instance',
varStyle: styledone
},
{
varID: 2345,
varDesc: 'Boot up the computer',
varStyle: styledone
},
{
varID: 2787,
varDesc: 'Open Google Chrome',
varStyle: styledone
}
],
}
})
body {
margin: 0
}
#app {
margin: 2%;
justify-content: center;
align-items: center;
}
.header {
height: 100px;
background: linear-gradient(90deg, rgba(162,148,203,0.7651435574229692) 0%, rgba(228,147,205,1) 50%, rgba(169,163,214,0.7035189075630253) 100%);
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 30px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
.todobox {
display: inline-block;
border: 2px black solid;
border-radius: 5%;
color: white;
margin-left: 2rem;
margin-top: 2rem;
-webkit-box-shadow: 14px 10px 5px -1px rgba(255,153,255,1);
-moz-box-shadow: 14px 10px 5px -1px rgba(255,153,255,1);
box-shadow: 14px 10px 5px -1px rgba(255,153,255,1);
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
}
.undone {
background-color: crimson;
}
.done {
text-decoration: line-through;
background-color: gray;
}
.todobox:hover {
cursor: pointer;
}
.todobox:active {
box-shadow: none;
transition: all 0.3s
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta name="viewpoint" content="width=devide-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<title>ToDo List</code>>
</head>
<body>
<div class="header">
<h1>Todo List</h1>
</div>
<div id="app">
<div class="todobox"
v-for="variant in variants"
:key="variant.varID"
:style="{ variant.varStyle }">
<p>{{ variant.varDesc }}</p>
</div>
</div>
<script src="/main.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">