1.添加代码:
<el-table-column lable="操作"> <template slot-scope="scope"> <el-button type="success">编辑 <i class="el-icon-edit"></i></el-button> <el-button type="danger">删除 <i class="el-icon-remove-outline"></i></el-button> </template> </el-table-column>
2.添加后的代码:
<!--border stripe,表示加上斑马线--> <!--header-row-class-name="headerBg",表示设置表头颜色样式,headerBg为一个style样式类--> <el-table :data="tableData" border stripe :header-cell-class-name="headerBg"> <el-table-column prop="date" label="日期" width="140"> </el-table-column> <el-table-column prop="name" label="姓名" width="120"> </el-table-column> <el-table-column prop="address" label="地址"> </el-table-column> <el-table-column lable="操作"> <template slot-scope="scope"> <el-button type="success">编辑 <i class="el-icon-edit"></i></el-button> <el-button type="danger">删除 <i class="el-icon-remove-outline"></i></el-button> </template> </el-table-column> </el-table>
3.最终编写好的el-main
<el-main> <div style="padding: 10px 0px"> <!--prefix-icon="el-icon-user",表示加一个搜素图标,设置在头--> <!--suffix-icon="el-icon-tickets"",表示加一个搜素图标,设置在尾--> <!--placeholder="请输入内容"",表示设置一个默认显示提示文字内容--> <el-input style="width: 200px" placeholder="请输入人名" prefix-icon="el-icon-user"></el-input> <el-input style="width: 200px" placeholder="请输入标题" suffix-icon="el-icon-tickets" class="ml-5"></el-input> <el-input style="width: 200px" placeholder="请输入url" prefix-icon="el-icon-link " class="ml-5"></el-input> <el-button class="ml-5" type="primary">搜索</el-button> </div> <!--两个div层之间都用margin,则会自动隔开--> <div style="margin: 10px 0px"> <el-button type="primary">新增 <i class="el-icon-circle-plus-outline"></i></el-button> <el-button type="danger">批量删除 <i class="el-icon-remove-outline"></i></el-button> <el-button type="primary">导入 <i class="el-icon-bottom"></i></el-button> <el-button type="primary">导出 <i class="el-icon-top"></i></el-button> </div> <!--border stripe,表示加上斑马线--> <!--header-row-class-name="headerBg",表示设置表头颜色样式,headerBg为一个style样式类--> <el-table :data="tableData" border stripe :header-cell-class-name="headerBg"> <el-table-column prop="date" label="日期" width="140"> </el-table-column> <el-table-column prop="name" label="姓名" width="120"> </el-table-column> <el-table-column prop="address" label="地址"> </el-table-column> <el-table-column lable="操作"> <template slot-scope="scope"> <el-button type="success">编辑 <i class="el-icon-edit"></i></el-button> <el-button type="danger">删除 <i class="el-icon-remove-outline"></i></el-button> </template> </el-table-column> </el-table> <div style="padding: 10px 0px"> <!--内边距空一些--> <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4" :page-sizes="[5, 10, 15, 20]" :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="400"> </el-pagination> <!--1.page-sizes一般设置为5,10,15,20--> <!--1.page-size一般设置为10,即每页10个--> </div> </el-main>