国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Elementui表格組件+sortablejs實現行拖拽排序的示例代碼

2019-11-19 10:56:43
字體:
來源:轉載
供稿:網友

前言

運營小姐姐說想要可以直接拖拽排序的功能,原來在序號六的廣告可能會因為金主爸爸加錢換到序號一的位置,拖拽操作就很方便

效果

實現方式

template部分

<el-table v-loading="loading" :default-sort="{prop: 'sortNum', order: 'ascending'}" :data="list" border align="left"> <el-table-column  show-overflow-tooltip  v-for="(item, index) in col"  :key="`col_${index}`"  :prop="col[index].prop"  :label="item.label" >  <template slot-scope="scope">   <p>{{scope.row[item.prop]}}</p>   </template> </el-table-column></el-table>

script部分

import Sortable from 'sortablejs'export default { components: { Sortable }, data() { return {  col: [  {   label: '位置',   prop: 'location'  },  {   label: '序號',   prop: 'sortNum'  },  {   label: '經辦人',   prop: 'operator'  },  {   label: '操作',   prop: 'isClick'  }  ] } }, mounted() { this.rowDrop() }, methods: {  rowDrop() {  const tbody = document.querySelector('.el-table__body-wrapper tbody')  const _this = this  Sortable.create(tbody, {   onEnd({ newIndex, oldIndex }) {    const currRow = _this.list.splice(oldIndex, 1)[0]    _this.list.splice(newIndex, 0, currRow)    _this.list = _this.list.filter(({ adId }) => adId !== 0)     _this.list.forEach((item, index) => {     _this.sortString += item.adId + ':' + (index + 1) + ','    })    _this.sortString = _this.sortString.substr(0, _this.sortString.length - 1)   }  }) } }}

完成!你們可以看得懂的!你可以你能行!

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邹城市| 淮北市| 仁怀市| 蕉岭县| 文昌市| 普洱| 岱山县| 冷水江市| 长沙县| 偃师市| 文登市| 山东省| 江川县| 凤冈县| 桦川县| 武功县| 德清县| 观塘区| 安阳市| 永城市| 昭觉县| 藁城市| 东平县| 金寨县| 巨野县| 沾化县| 成武县| 松江区| 龙口市| 馆陶县| 犍为县| 永和县| 昌吉市| 河池市| 梨树县| 沙坪坝区| 板桥市| 西贡区| 南华县| 莒南县| 磐安县|