Created
July 28, 2021 11:47
-
-
Save redamoon/21779331079550d55f526847e3cd0233 to your computer and use it in GitHub Desktop.
poPLzzd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<div v-for="(v, i) in fliterTagList"> | |
<div>{{ v.label }}</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const endpoint = { | |
"contents": [ | |
{ | |
"tag": [ | |
{ | |
"id": "4-p2z49d-2na", | |
"createdAt": "2021-07-26T13:49:21.242Z", | |
"updatedAt": "2021-07-26T13:49:21.242Z", | |
"publishedAt": "2021-07-26T13:49:21.242Z", | |
"revisedAt": "2021-07-26T13:49:21.242Z", | |
"label": "Next.js", | |
"slug": "Nextjs" | |
}, | |
{ | |
"id": "4-p2z49d-2na", | |
"createdAt": "2021-07-26T13:49:21.242Z", | |
"updatedAt": "2021-07-26T13:49:21.242Z", | |
"publishedAt": "2021-07-26T13:49:21.242Z", | |
"revisedAt": "2021-07-26T13:49:21.242Z", | |
"label": "Movable Type", | |
"slug": "Movabletype" | |
} | |
] | |
}, | |
{ | |
"tag": [ | |
{ | |
"id": "4-p2z49d-2na", | |
"createdAt": "2021-07-26T13:49:21.242Z", | |
"updatedAt": "2021-07-26T13:49:21.242Z", | |
"publishedAt": "2021-07-26T13:49:21.242Z", | |
"revisedAt": "2021-07-26T13:49:21.242Z", | |
"label": "Next.js", | |
"slug": "Nextjs" | |
} | |
] | |
} | |
], | |
"totalCount": 2, | |
"offset": 0, | |
"limit": 10 | |
} | |
const vm = new Vue({ | |
el: '#app', | |
data() { | |
return { | |
data: endpoint | |
} | |
}, | |
computed: { | |
fliterTagList() { | |
const getTagList = this.data.contents.map((v, i) => v.tag).flat(1) | |
return [...new Map(getTagList.map(v => [v.label, v])).values()] | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment