Last active
May 12, 2018 18:52
-
-
Save menuka94/a66ebaa9c1231df820f64e0f5bfc1356 to your computer and use it in GitHub Desktop.
VueJS Snippets
This file contains hidden or 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" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-bind="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="root"> | |
<li v-for="name in names"> | |
{{name}} | |
</li> | |
<input id="input" type="text" v-model="newName"> | |
<button @click="addName" :title="title">Add Name</button> | |
</div> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
<script> | |
var app = new Vue({ | |
el: '#root', | |
data: { | |
newName: '', | |
names: ['Joe', 'Mary', 'Jane', 'Jack'], | |
title: 'button' | |
}, | |
methods: { | |
addName() { | |
this.names.push(this.newName); | |
this.newName = ''; | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment