Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
converting Vue components to Typescript
import { ListItem } from '@/types/index';
import { Component, Prop, Model, Provide, Watch, Vue } from 'vue-property-decorator';
import LIST from './../../../data/starters';
import SearchItem from './SearchItem.vue';
import SearchForm from './SearchForm.vue';
@Component({
name: 'Search',
components: {
SearchItem,
SearchForm,
},
})
export default class Search extends Vue {
public list: ListItem[] = LIST;
public labels: string[] = [];
public results: ListItem[] = [];
private components = {
SearchItem,
SearchForm,
};
private mounted() {
this.results = this.list;
this.list.forEach( (l) => {
this.labels = this.labels.concat(l.features);
});
this.labels = [...new Set(this.labels)];
}
private onSeachTextChanged(val: string) {
this.results = this.list.filter((i: ListItem) => {
return i.title.toLowerCase().includes(val.toLowerCase());
});
}
private onSeachTagChanged(val: string) {
this.results = this.list.filter((i: ListItem) => {
return i.features.includes(val);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.