Use the drop-down selector to switch echarts plots

The first option is selected by default

1. Page use selector

<el-select size="small" class="drop_down_list color_search" v-model="value"
             @change="searchSelect(value)" title="请选择饲喂模式">
      <template v-for="item in feedingStrategyMajor">
           <el-option
             :key="item.type"
             :value="item.type"
             :label="item.title">
           </el-option>
      </template>
</el-select>
        data() {
            return {
                
                value: 1,
                majorType: 1,
                feedingStrategyMajor: [], //存后台获取的数据
            }
        },

2.Event

            //获取选择器数据
            searchSelect(majorType) {
                this.majorType = majorType;

                this.$refs.mychild.getAllCurves(0, "", majorType); //我调用的组件里面的事件
            },

this.$refs.mychild.getAllCurves(0, "", majorType); //The method in the component I called, here is the method called to get the curve data

Example: Get curve data--here is the event in the component

            //获取曲线所有数据
            getAllCurves(index, paramsName,majorType) {
                this.indexComponent = index;
                if (index != this.getAllCurvesIndex){
                    this.getAllCurvesIndex = 0
                }
                if (majorType != undefined){
                    this.majorType = majorType;
                }
                this.getAllCurvesIndex = index;
                polylineData('get', {
                    majorType: this.majorType
                }).then(res => {
                    const seriesArr = [];
                    const waterData = [];
                    const feedData = [];
                    if (res.code == 200) {
                        //获取全部折线数据
                        this.feedTitle = res.data.userFeedingCurves;
                        ......................省略

 

Guess you like

Origin blog.csdn.net/lovexiuwei/article/details/117415790