The problem that the display cannot be refreshed when using Echarts charts in subcomponents (solution: subcomponent refresh)

scene problem

In the project, the chart of Echarts is used in the child component. The data of the chart needs to be queried by passing in the Id from the parent component. The moisture meter has the same structure as the weather station. When the device is switched, the chart cannot be echoed, and the parent-child component passes the value normal.

insert image description here

Solve the mental journey

1. I passed the Id of the value of the two devices separately, and the processing failed.
2. Assign a key to the subcomponent, click the device identification key++ each time, and the revision is successful

          <template v-if="instrumentValue == 0  && facilityId != ''">
            <SoilMositure :facilityNo="facilityNo" :facilityId="facilityId" :key="childKey.soilMositure" ></SoilMositure>
          </template>
          <template v-else-if="instrumentValue == 1 && facilityId != ''">
            <WeatherStation :facilityNo="facilityNo" :facilityId="facilityId" :stationName="facilityName" :key="childKey.weatherStation"></WeatherStation>
          </template>

Guess you like

Origin blog.csdn.net/lzl980111/article/details/124118780