1👍
This issue happens because your component’s current_category
, filterByCategory
function and services
isn’t recognized by TypeScript. These functions can be added by using the interface
. You need to define these types first like this.
interface MyComponent {
current_category: string;
filterByCategory(array: any): any;
services: any[];
filteredProducts(): any;
}
export default {
name: 'HomePage',
components: {},
methods: {
filterByCategory(array: any) {
return array.filter((service: any) => service.type == this.current_category);
}
},
data(): MyComponent {
return {
current_category: "xxx",
services: [],
filteredProducts() {
return this.filterByCategory(this.services);
}
};
},
mounted() {},
};
- [Vuejs]-How to remove Bootstrap from .NET Core Template
- [Vuejs]-Cannot deploy Vue apps on GitHub Pages
Source:stackexchange.com