I am encountering an issue in my Vue application where I am trying to filter an array received from map getters based on a type prop within a computed property. Despite verifying that both the array elements and the prop are strings, the filtering process is not functioning correctly. It appears that the computed property may be called before the prop is fully initialized with a value. Can someone provide assistance with this problem?
all: 'mdm/all', // 'mdm' denotes module name and 'all' represents the state
prop: [type]
Within the computed property, there is a method named
getData() {
const filteredData = this.all.filter(ele => ele.type === this.type.toLowerCase());
return filteredData.map(item => (
{name: item.name,
orderNo: item.order_no
});
}
Despite both ele.type
and this.type
showing similar string values (e.g., 'expired'), the resulting filteredData always ends up as an empty array.
I am unsure of what might be causing this issue.