1
VueJS 2の項目のリストをslice()。sort()でソートしようとしましたが、効果がありません。 vuejs 1では素晴らしいorderByフィルタがありましたが、これを削除しました。現在の設定は次のとおりです。VueJSで並べ替える2
<table>
<thead>
<tr>
<th v-for="column in columns" v-on:click="sortBy(column)">{{ column }}</th>
</tr>
</thead>
<tbody>
<tr v-for="customer in customerslist">
<td>{{ customer.firstname }}</td>
<td>{{ customer.surname }}</td>
<td>{{ customer.added }}</td>
<td></td>
</tr>
</tbody>
</table>
...
sortBy(sortKey) {
this.customerslist = this.customerslist.slice().sort(sortKey);
console.log(sortKey);
console.log(this.customerslist[0].firstname);
}
これは2次元配列の顧客です。各顧客には、名字、姓、および追加フィールドがあります。
しかし、firstname列ヘッダーをクリックすると、これは常にアルファベット順ではないのに、同じfirstnameをコンソールに返します。並べ替えはどのように機能するのですか。私は正しい文書を見つけることができません。