To eliminate duplicate values, I wrote the following code:
vue
<div class="col-md-6" style="float: left">
<ul class="list-group">
<li class="list-group-item"
:class="{ active: index1 == currentIndex1 }"
v-for="(member, index1) in uniqueMemName"
v-bind:value="member.mem_name"
:key="index1"
@click="setActiveMember(member, index1)"
>
<strong style="margin-bottom: 5px"> {{member.mem_name}} </strong>
</li>
</ul>
</div>
vue (script)
computed: {
uniqueMemName() {
return _.uniqBy(this.members, function(m) {
return m.mem_name;
});
}
},
I have also installed lodash. However, an error is occurring. Can you identify the incorrect part?
If there is a different method than the one I used, please share.
Error displayed in console:
Array information for reference:
In my database, I have tables A and B. Table A contains only the mem_name column, while table B includes all columns.
Example ->
a.mem_name | b.col1 | b.col2 |
---|---|---|
mem1 | 10 | 20 |
mem1 | 30 | 40 |
mem2 | 50 | 60 |
Currently, I am working on consolidating duplicate mem_names using lodash's unique functionality.