0
如何在沒有插件的情況下對Vue.js中的數據進行排序。我有這樣在沒有插件的情況下對Vue.js中的數據進行排序
var people = [
{
id: 1,
firstName: "John",
lastName: "Doe",
email: "[email protected]",
dob: "12/12/12"
},
{
id: 2,
firstName: "Jane",
lastName: "Smith",
email: "[email protected]",
dob: "11/11/11"
},
{
id: 3,
firstName: "Brian",
lastName: "Rogers",
email: "[email protected]",
dob: "10/10/10"
}
];
JSON數據如何排序,他們到遞減或遞增表,並在表頭是當表頭的用戶點擊後,圖標會動態地改變添加圖標。
例如,當數據是從最高到最低的圖標會fa-sort-amount-desc
我的表的代碼看起來像這樣
<div class="row">
<div class="col-xs-12" v-if="!laravelData || laravelData.total === 0"><em>No data available.</em></div>
<div class="col-xs-12">
<div class="table-scrollable">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th> ID</th>
<th> First Name</th>
<th> Last Name</th>
<th> Email </th>
<th> DOB </th>
</tr>
</thead>
<tbody>
<tr v-for="data in laravelData.data" :key="data.title">
<td> <a :href="data.account_link">@{{ data.id }}</a> </td>
<td> @{{ data.firstName }}</td>
<td> @{{ data.lastName }} </td>
<td class="text-right"> @{{ data.email }} </td>
<td class="text-right"> @{{ data.dob }} </td>
</tr>
<tr v-if="!laravelData || laravelData.total === 0">
<td colspan="13"><em>No data available.</em></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
我認爲你可以使用V-綁定類= 'FA-排序量降序排序':用於遞減數據條件,「FA- sort-amount-aesc':for aesc數據條件 – Abhishek