element 官网上 slot=“header”,这种写法,template 内不能获取到provinceName 和cityName的值,打印出来的一直是初始值,将slot=“header” 改成#header ,就可以了
<el-table-column ><template #header><ul><li class="tebleHeader">省份</li><li v-for="(item,index) in 22" :key="index" :class="'tebleHeader'+index"><template v-if="provinceName !== '全国'">{
{provinceName}}-{
{cityName}}</template><template v-else>{
{provinceName}}</template></li></ul></template>
</el-table-column>
export default{data(){return{provinceName:"全国",cityCode: '',}},methods:{changeShow(){ this.provinceList.map((item)=>{//获取到当前的省份nameif (item.provinceCode == this.provinceCode) {this.provinceName = item.provinceNameif (item.children) {this.cityList = item.childrenthis.cityName = '全部'}}})this.cityList.map((item)=>{//获取到当前查询的市nameif (item.cityCode == this.cityCode) {this.cityName = item.cityName}})},}}