我的表基于Vue.js网站上的网格组件示例
我在表中排序日期时遇到问题.我从服务器端获取所有表数据作为JSON.所以在提供的代码中,我只是模拟了var mockDataFromServerSide中的数据.
这是代码:https://jsfiddle.net/5w1wzhvw/3/
HTML文件:
<!-- component template -->
<script type="text/x-template" id="grid-template">
<table>
<thead>
<tr>
<th v-for="key in columns"
v-on:click="sortBy(key)"
:class="{active: sortKey == key}">
{{key | capitalize}}
<span class="arrow"
:class="sortOrders[key] > 0 ? 'asc' : 'dsc'">
</span>
</th>
</tr>
</thead>
<tbody>
<tr v-for="
entry in data
| filterBy filterKey
| orderBy sortKey sortOrders[sortKey]">
<td v-for="key in columns">
{{entry[key]}}
</td>
</tr>
</tbody>
</table>
</script>
<!-- demo root element -->
<div id="demo">
<form id="search"> …Run Code Online (Sandbox Code Playgroud)