I have lots of results that display from a component. Im having problems with the location data which I want to display in the component. Its sitting as multiple elements with | to separate them. How do I filter down to remove all duplicates in each result and display it as a comma separated list.
I would like the data to appear from the component
Title: Holiday One Location:AZ,FL,TX,MA,AZ,MS,TN,AL
Title: Holiday two Location:TN,AZ,FL,AL
Title: Holiday three Location:AZ,NY,WY,TN,FL, AL
The main page
<result
v-for="(result, index) in results"
:result="result"
:index="index"
/>
This is the result component.
<template>
<div>
<div v-if="location">{{ location }}
</div>
<script>
export default {
name: "result",
props: {
result: Object,
},
data: function () {
return {
location: this.result.location,
</script>
JSON
"results": {
"title": "Holiday one",
"location": "AZ|AZ|FL|TX",
"location": "MA|AZ|MS|TX",
"location": "TN|AZ|FL|AL",
"date": "22/08/2022",
},
"results": {
"title": "Holiday two",
"location": "TN|AZ|FL|AL",
"date": "20/08/2022",
},
"results": {
"title": "Holiday three",
"location": "AZ|NY|NY|WY",
"location": "TN|AZ|FL|AL",
"date": "10/08/2022",
},
"results": {
"title": "Holiday four",
"location": "MA|AZ|MS|TX",
"location": "TN",
"location": "CN",
"date": "14/08/2022",
},
"results": {
"title": "Holiday five",
"location": "CL|VT|NB|TX",
"location": "RI|NH ",
"location": "TX",
"location": "SC|NC",
"date": "18/08/2022",
},
Any help appreciated
|to create the array and use av-forto render each of the resulting items