Answer the question
In order to leave comments, you need to log in
Vue + Typescript dynamic action/getter namespace?
@Template
@Component<ComponentClass>(
{
components: {},
mixins: [],
directives: {},
},
)
export default class ComponentClass extends Vue
@Prop({ type: String, required: true })
dynamicNamespaceProp!: string[];
@namespace(dynamicNamespaceProp).Getter
someGetter!: { [key: string]: string };
get dynamicNamespace() : string {
return this.dynamicNamespaceProp;
}
mounted(): void {
}
};
Answer the question
In order to leave comments, you need to log in
@Prop({type: String, required: true})
namespace!: string;
get currentStep(): any {
return store.getters[`${this.namespace}/currentStep`];
}
computed: {
...mapState(`${LISTS}/${PUBLIC_NOT_SECURED}`, {
// dynamic getters
// DO NOT MODIFY "RVALUE"!
list(state, getters) {
return getters[`${this.namespace}/list`];
},
setFieldValueByFieldNameFromEvent ($event: InputEvent): Promise<object>{
return store.dispatch(`${this.namespace}/setFieldValueByFieldNameFromEvent`, $event);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question