Skip to content

Instantly share code, notes, and snippets.

@menuka94
Last active May 12, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menuka94/a66ebaa9c1231df820f64e0f5bfc1356 to your computer and use it in GitHub Desktop.
Save menuka94/a66ebaa9c1231df820f64e0f5bfc1356 to your computer and use it in GitHub Desktop.
VueJS Snippets
<!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