JSFiddle - React, Tailwind, and code Playground
by greene48
HTML
<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/0.7.0/vue-resource.js"></script>
<div id="demo" class="window">
<table class="vu-table">
<thead>
<tr>
<th v-for="head in columns" nowrap>
{{head}}
</th>
</tr>
</thead>
<tbody class="vu-body">
<tr v-for="item in data_list">
<td v-for="head in columns">
{{item[head]}}
</td>
</tr>
</tbody>
</table>
</div>
CSS
body {
font-family: Helvetica Neue, Arial, sans-serif;
font-size: 14px;
color: #444;
}
table {
border: 2px solid #42b983;
border-radius: 3px;
background-color: #fff;
}
th {
background-color: #42b983;
color: rgba(255,255,255,0.66);
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-user-select: none;
}
td {
background-color: #f9f9f9;
}
th, td {
min-width: 60px;
padding: 10px 10px;
}
th.active {
color: #fff;
}
th.active .arrow {
opacity: 1;
}
.arrow {
display: inline-block;
vertical-align: middle;
width: 0;
height: 0;
margin-left: 5px;
opacity: 0.66;
}
.arrow.asc {
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 4px solid #fff;
}
.arrow.dsc {
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
#search {
margin-bottom: 10px;
}
JavaScript
var vm = new Vue({
el: '#demo',
data: {
columns: ['userId', 'id', 'title', 'body'],
data_list: []
},
ready: function() {
this.$http.get('http://jsonplaceholder.typicode.com/posts').then(function (response) {
this.$set('data_list', response.data)
});
},
})