vue动态添加事件的问题

项目是vue+element-ui的表格,是一个多级表头,项目中有很多多级表头就写了公用组件,遍历传过来的数据


<el-table-column v-for="(data,index) in columnsTable"

                         :label="data.tierData.titleName"

                         :key="index"

                         v-if="color"

                         align="center">


            <el-table-column v-for="(list,index) in data.tierData.content"

                           :key="list.text"

                           :label="list.text"

                           :prop="list.dataIndex">

              <template scope="scope">

                {{scope.row[list.dataIndex]}}

              </template>

            </el-table-column>

      </el-table-column>

https://img4.mukewang.com/5c6cf0ad0001438e05020371.jpg

https://img1.mukewang.com/5c6cf0ae0001771b02260099.jpg



我的问题是,现在需求是有一个选择器可以控制隐藏一列表格,例如:选择地址,表格中这个多级的列都要隐藏,还请大家给个思路


汪汪一只猫
浏览 1831回答 2
2回答

一只甜甜圈

看你给的代码是两级表头data:{&nbsp; &nbsp; firstHeadHidden: '',&nbsp; &nbsp; secondHeadHidden: ''}<el-table-column v-for="(data,index) in columnsTable"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:label="data.tierData.titleName"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:key="index"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;v-if="color || data.tierData.titleName !== firstHeadHidden"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;align="center">&nbsp; <el-table-column v-for="(list,index) in data.tierData.content"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:key="list.text"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:label="list.text"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:prop="list.dataIndex"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;v-if="list.text !== secondHeadHidden">&nbsp; &nbsp; <template scope="scope">&nbsp; &nbsp; &nbsp; {{scope.row[list.dataIndex]}}&nbsp; &nbsp; </template>&nbsp; </el-table-column></el-table-column>

陪伴而非守候

我想到就是控制你的content,你点地址就把地址的data从content中拿出来,这样你渲染的就不包含地址了,选择其他的再把其他的data拿出来,同时把地址的data放回去
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript