Currently, I am in the process of migrating from Vue2 to Vue3 with TypeScript and Module Decorators. I have encountered an issue while trying to use the find
function.
@Module
export default class TagsModule extends VuexModule {
data = {};
get AllTag() {
return (id) => {
return this.data.find(tag => tag.id === id)
};
}
}
An error message is displayed:
Property 'find' does not exist on type '{}'.
My objective is as follows:
- I intend to pass a string to the
AllTag
method and employ it for searching within thedata
The structure of the data is as follows:
[
{
"id": 2,
"created_at": null,
"updated_at": null,
"created_by": 1,
"status": null,
"uid": null,
"name": "Testtaag",
"class": "light-danger"
}, {
"id": 1,
"created_at": null,
"updated_at": null,
"created_by": 1,
"status": null,
"uid": null,
"name": "tihS",
"class": "light-warning"
}
]