I have a table component in a .vue file that and i'm trying to show some icons based on the dir of the order clicked
example:
<th v-for="(column, index) in columns" :key="index" @click="sort( index )">
<span>{{ column.label }}
<i v-if="column.dir == 'desc'" class="fa fa-sort-down"></i>
<i v-else class="fa fa-sort-up"></i>
</span>
The above is what the layout of the header is and my default column object looks like this:
data().....
columns: [
{
label: '#',
order: false,
search: false,
column: 'id',
dir: 'desc'
},
{
label: 'Username',
order: true,
search: true,
column: 'username',
dir: 'desc'
}]
Now in my sort method, i update the clicked column
var col = this.columns[column];
col.dir = ( col.dir == 'desc' ) ? 'asc' : 'desc';
// I tried to no avail
this.$set(this.columns, index, col);
Vue.set(this.columns, index, col);
Also
this.$nextTick(function() {
columns[index].dir = ( columns[index].dir == 'desc' ) ? 'asc' : 'desc';
});
if i check my Vue dev tool, i can see the value updated but the reactivity never gets back to the main columns object and the view isnt update to show the else portion.
Probably not grasping the concept firmly, any help will be greatly appreciated. Thanks
UPDATE.....
Thanks so much for the help, so i happens that font-awesome was removing the from the DOM and replacing it with an SVG making it impossible for vue js to find it.
I will still choose an answer below nonetheless.
indexas key. Instead, use a unique identifier. Saycolumn?