慕尼黑5688855
您需要filter()根据点击的按钮使用请检查以下工作代码片段const projects = [{ ids: '5', cate: 'Technical', title: 'Top 10 Australian beaches', date: 'November 10', name: 'Whitehaven Beach', place: 'Whitsunday Island, Whitsunday Islands', sorce: 'https://cdn.vuetifyjs.com/images/cards/docks.jpg' }, { ids: '5', cate: 'Sports', title: 'Top 10 Australian beaches', date: 'November 21', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/house.jpg' }, { ids: '1', cate: 'Music', title: 'Top 10 Australian beaches', date: 'December 22', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/road.jpg' }, { ids: '2', cate: 'Creative', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/plane.jpg' }, { ids: '5', cate: 'Sports', title: 'Top 10 Australian beaches', date: 'November 25', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/house.jpg' }, { ids: '1', cate: 'Music', title: 'Top 10 Australian beaches', date: 'November 22', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/road.jpg' }, { ids: '1', cate: 'Adventure', title: 'Top 10 Australian beaches', date: 'November 12', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/plane.jpg' }, { ids: '5', cate: 'Sports', title: 'Top 10 Australian beaches', date: 'December 23', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/house.jpg' }, { ids: '1', cate: 'Music', title: 'Top 10 Australian beaches', date: 'November 17', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/road.jpg' }, { ids: '1', cate: 'Adventure', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/plane.jpg' }, { ids: '5', cate: 'Sports', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/house.jpg' }, { ids: '1', cate: 'Music', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/road.jpg' }, { ids: '2', cate: 'Creative', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/plane.jpg' }, { ids: '5', cate: 'Sports', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/house.jpg' }, { ids: '1', cate: 'Music', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/road.jpg' }, { ids: '2', cate: 'Creative', title: 'Top 10 Australian beaches', date: 'November 20', name: 'Whitehaven Beach', place: 'Block 15, Near Tuck Shop', sorce: 'https://cdn.vuetifyjs.com/images/cards/plane.jpg' },];new Vue({ el: '#app', methods: { filter(event){ if(event.target.innerText.toLowerCase() != 'all'){ console.log(this.projects.filter(({cate})=>cate.toLowerCase() == event.target.innerText.toLowerCase())); } else{console.log(this.projects)} } }, data: { projects:projects }})<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script><div id="app"> <button @click="filter($event)" class="ma-2" outlined color="indigo">All</button> <button @click="filter($event)" class="ma-2" outlined color="indigo">Adventure</button> <button @click="filter($event)" class="ma-2" outlined color="indigo" @click="filter($event)" >Creative</button> <button class="ma-2" outlined color="indigo" @click="filter($event)" >Entertainment</button> <button @click="filter($event)" class="ma-2" outlined color="indigo">Startups</button> <button @click="filter($event)" class="ma-2" outlined color="indigo">Gaming </button> <button @click="filter($event)" class="ma-2" outlined color="indigo">Technical</button> <button class="ma-2" outlined color="indigo" @click="filter($event)">Sports</button></div>