Answer the question
In order to leave comments, you need to log in
How to add name to multiple entities with store?
I want to add the name of each entity through its id, but I don’t get the name, please help me solve the problem
Here I monitor the metrics that change and if the condition works, I pass the metric objects with the metric id key and the value of its name in store mutationswatch: {
metric() {
if (this.metric) {
this.setSingleMetricNamesMap({ [this.metric.id]: this.metric.name })
}
}
},
state
I understand that primitive types are preferable for vuex, I tried to set the value to null, but then several objects (metrics) are not added to the state
state getter , I
try to return the name of the metric for the identifier, instead of an object containing the names and identifiers of the metric.singleMetricNamesMap: []
singleMetricNamesMap: state => state.singleMetricNamesMap
state mutations
Write metric objects to statesetSingleMetricNamesMap: (state, val) => {
state.singleMetricNamesMap.push(val)
},
The component where I call the state getter and try to get the names of the metrics by their IdshowNames() {
return this.singleMetricNamesMap.forEach(el => el[this.value.metricId])
}
<z-dash-tile-config-option
label="Metric"
:value="showNames" // здесь делаю bind имен для метриков
>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question