JSFiddle - React, Tailwind, and code Playground
by Amresh Venugopal
HTML
<script src='https://unpkg.com/[email protected]/dist/vue.js'></script>
<div id="app">
<template v-for="player in players">
<div class="player">{{ player }}
<div class="health-bar">
<div class="health"></div>
</div>
</div>
<button @click='magic'></button>
</template>
</div>
CSS
body {
background: white;
}
.player {
border: 1px solid #eee;
display: inline-block;
width: 45%;
text-align: center;
margin: 2px 13px;
font-size: 18px;
font-weight: bold;
text-transform: uppercase;
}
.health-bar {
width: 90%;
height: 30px;
background: #eee;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin: 5px 13px;
}
.health {
background: #4da;
width: 40%;
height: 100%;
}
JavaScript
new Vue({
el: '#app',
data: {
players: ["You", "Monster"]
},
methods: {
magic: function() {
alert('magic')
this.expect = "magic!";
}
}
});