1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > vue使用elementui实现表格中上下移动功能

vue使用elementui实现表格中上下移动功能

时间:2022-06-13 12:00:49

相关推荐

vue使用elementui实现表格中上下移动功能

html代码

<el-table :data="prodata"><el-table-column align="center" label="操作"><template slot-scope="scope"><el-button @click="upLayer(scope.$index,scope.row)">上移</el-button><el-button @click="downLayer(scope.$index,scope.row)" >下移 </el-button></template></el-table-column></el-table>

js代码

upLayer(index, row) {var that = this;if (index == 0) {that.$message({message: "处于顶端,不能继续上移",type: "warning"});} else {let upDate = that.prodata[index - 1];that.prodata.splice(index - 1, 1);that.prodata.splice(index, 0, upDate);}},downLayer(index, row) {var that = this;if (index + 1 === that.prodata.length) {that.$message({message: "处于末端端,不能继续下移",type: "warning"});} else {let downDate = that.prodata[index + 1];that.prodata.splice(index + 1, 1);that.prodata.splice(index, 0, downDate);}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。