Hello there!
I'm currently working on a Vue.js project and using modules. I am trying to get filtered data from a getter, but I'm unsure how to provide parameters.
Specifically, I need to pass a 'name' parameter to the Getter. How can I achieve this in my Component.vue file?
/*State in vuex*/
state: {
tempMessageValues: [
{ name: 'RU', status: 'none', selected: false },
{ name: 'BY', status: 'none', selected: false },
{ name: 'KG', status: 'none', selected: false }
]
}
/*Getters*/
import * as types from '../types';
export default {
[types.GETTERS.TEMP_MESSAGE_VALUES]: state => {
return state.tempMessageValues.find(country => country.name === name);
}
};
/*Types*/
export const GETTERS = {
TEMP_MESSAGE_VALUES: 'shared/TEMP_MESSAGE_VALUES'
};
/*Code in Component.vue*/
import * as types from "./store/types";
import { mapGetters } from "vuex";
export default {
computed: {
...mapGetters({
getTempMessValues: types.GETTERS.TEMP_MESSAGE_VALUES
})
}
};