0
Vue js 2を使用してソート可能なテーブルを作成しようとしています。私は既にテーブルを生成しています。Vue js 2テーブルソート
<thead>
<tr>
<th class="table-header">Metric</th>
<th class="table-header" v-for="metric in metricList"><a href="#">{{metric}}</a></th>
</tr>
</thead>
<tbody>
<template v-for="item in metricItem">
<tr>
<td class="table-cell" style="font-weight:bold"> {{ item }}</td>
<template v-for="metric in metricList">
<td class="table-cell">
{{getData[item][metric]}}
</td>
</template>
</tr>
</template>
</tbody>
<script>
import { mapGetters, mapMutations } from 'vuex';
export default {
name: 'scores',
data(){
return {
metricList : ["Current", "Min", "Avg", "Max"],
metricItem : [
'Happiness Score',
'Sadness Score'
]
}
},
computed: {
...mapGetters ([
'getData', //getter to get data
])
}
}
</script>
をし、データセットは、このようなものです::
私のコードは、以下を参照してください
getData {
Happiness Score {
Min : 62,
Max : 154,
Avg : 103
Current : 100
},
Sadness Score {
Min : 66,
Max : 54,
Avg : 73
Current : 45
},
}
私が使用してソート可能なテーブルを作成しようとしていますVueのJS 2.私は既に持っていますテーブルを生成し、このテーブルをどのようにソートするのかと思っています。
ありがとう、それはうまく動作します。しかし、2回目のクリックをしたときに降順にしたいのですが? –
変数内の注文をクリックまたはマークするときは、現在の注文を確認してください。 – choasia