Add drop-down boxes and other components to the elementUI table header

The official website provides a way to use it directly

If it’s a simple header, just use it directly. If it’s a composite header, just add a template under the composite header and add the code for the composite header directly.

<el-table-column prop="title" :label="title" align="center">
        <template slot-scope="scope" slot="header">
            <el-select size="mini"  v-model="selectArea" @change="selectAreaChange" placeholder="请选择">
              <el-option
                v-for="item in optionAreas"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
           <el-select  size="mini"  v-model="selectYear" @change="selectYearChange" placeholder="请选择">
              <el-option
                v-for="item in optionYears"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
              <div class="titleDiv">xxx</div>
         
        </template>

        <el-table-column prop="all" label="xx" min-width="20%">
          <template slot-scope="scope">
            <span>{
   
   { scope.row.all }}</span>
          </template>
        </el-table-column>
      //省略其他代码
</el-table-column>

 

Final effect

Guess you like

Origin blog.csdn.net/CarryBest/article/details/90669135