进入模块后的效果图

 

列表html代码

这里需要注意的是el-table一定要有ref属性,比如ref="table"

  <div style="padding:0 1%;">
            <el-table  :data="lists"  v-loading="loading" ref="table" tooltip-effect="dark" @selection-change="handleSelectionChange" :height="height-220" border align="center">
            <el-table-column 
                type="selection"
                :width="width*0.05"> 
            </el-table-column>
            <el-table-column type=index label="序号" :index="typeIndex" :width="width*0.05" align="center"></el-table-column>  
            <el-table-column prop="picimg" label="图片" :width="width*0.25" align="center">
                <template slot-scope="scope">
                    <img  :src="scope.row.picimg" alt="" style="width: 100px;height:50px">
                </template>
            </el-table-column>
            <el-table-column prop="title" label="产品简称" :width="width*0.25" align="center"></el-table-column>
            <el-table-column prop="depict" label="产品描述" :width="width*0.25" align="center"></el-table-column>
            <el-table-column prop="picimg" label="图片" :width="width*0.25" align="center">
                <template slot-scope="scope">
                    <img  :src="scope.row.picimg" alt="" style="width: 100px;height:50px">
                </template>
            </el-table-column>
          
            </el-table>
           
        </div>

methods中的代码

请求完列表后进行回调操作,this.$refs.table.toggleRowSelection(this.lists[i],true) 是官网中给出的方法,第一个参数是需要被勾选的行组成的列表,第二个参数为true,必须要传。

getList(){
            let data={
                pageModel:{
                    pageNo:this.pageNo,
                    pageSize:this.limit
                },
                shop:{
                    style:this.radio
                }
            }
            listShop(data).then(res =>{
                this.total = res.data.data.total
                this.lists = res.data.data.rows.filter(res=>{
                    return res.isdelete == '0'
                })
            })
            //请求完列表后,回调,过滤需要被勾选的
            .then(()=>{
                for(let i=0;i<this.lists.length;i++){
                    if(this.lists[i].style == this.radio){
                        this.$refs.table.toggleRowSelection(this.lists[i],true);
                    }
                }
            })
        },

 

GitHub 加速计划 / eleme / element
13
1
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:1 个月前 )
c345bb45 1 年前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 1 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐