Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DMD4470/week-5/index.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (51 sloc)
1.39 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Vue Shopping List</title> | |
</head> | |
<body> | |
<main id="app"> | |
<h1>{{listTitle}}</h1> | |
<!--form--> | |
<!--Submit is doing the same thing as adding an event listener for the add button and clicking the enter key--> | |
<form @submit.prevent="addItem"> | |
<input type="text" name="" id="" v-model="newItem"> | |
<button type="submit">Add</button> | |
</form> | |
<hr> | |
<ul> | |
<li v-for="item in listItems"> | |
<input type="checkbox" name="" id=""> | |
<span>{{ item }}</span> | |
<a href="#" @click.prevent="deleteItem(item)">x</a> | |
</li> | |
</ul> | |
</main> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
<script> | |
var app = new Vue({ | |
el: '#app', | |
data: { | |
listTitle: 'Home Depot Shopping List', | |
listItems: [ | |
'nails', | |
'hammer' | |
], | |
newItem:'', | |
}, | |
methods:{ | |
addItem(){ | |
this.listItems.push(this.newItem); | |
this.newItem = ''; | |
}, | |
deleteItem(itemName){ | |
//alert(itemName) | |
this.listItems.splice(itemName,1); | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |