Skip to content

Instantly share code, notes, and snippets.

@danharr
Last active September 7, 2018 13:49
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 danharr/69a8cbafab815753c1df4d51c4de4589 to your computer and use it in GitHub Desktop.
Save danharr/69a8cbafab815753c1df4d51c4de4589 to your computer and use it in GitHub Desktop.
vue.js training
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<style>
.flex {
display:flex;
}
.menu-items {
padding:5px;
background:#045600;
color:white;
font-family:arial;
width:100%;
text-align:center;
}
button {
width:100%;
}
</style>
</head>
<body>
<div id="app">
<div id="menu" class="flex">
<div @click="menuClick(x)" class="menu-items" v-for="x in menu">{{x}}</div>
</div>
<h3>Some heading</h3>
<div class="flex">
<button @click="buttonClick(x)" v-for="x in buttons">{{x}}</button>
</div>
</div>
<script>
var menu = ['a','b','c','d'];
var buttons = ['a1','b2','c3','d4'];
var vm = new Vue({
el: '#app',
data: {
menu:menu,
buttons:buttons,
menuItem:'a'
},
methods: {
menuClick:function (f) {
this.menuItem = f;
} ,
buttonClick:function (f) {
}
}
})
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment