国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

vue+render+jsx實(shí)現(xiàn)可編輯動(dòng)態(tài)多級(jí)表頭table的實(shí)例代碼

瀏覽:3日期:2023-01-29 10:17:02

最近項(xiàng)目需要實(shí)現(xiàn)可編輯的動(dòng)態(tài)多級(jí)表頭表格,看了兩天的文章,始終沒(méi)有找到我想要的效果,在了解了render+jsx的基礎(chǔ)用法后,自己基于element-ui封裝了一個(gè),數(shù)據(jù)格式參考element-ui table的數(shù)據(jù)。實(shí)現(xiàn)如下:

1.scoresTable

<script> import scoresColumn from './scoresColumn'; export default { components: { scoresColumn }, render: function(h) { return <div className='table-control'><el-table ref='table' size='small' {...{attrs: {data:this.tableData}}} border> { this.tableTitles.map(title => { return <scoresColumn on-dataChange={this.dataChange} {...{attrs: {column:title,unitScores: this.unitScores}}}></scoresColumn> }) }</el-table> </div>; }, props: { tableTitles: {type: Array,default: () => [] }, tableData: {type: Array,default: () => [] }, unitScores: {type: Object,default: () => {} } }, methods: { dataChange(id) {this.$emit(’dataChange’, id); } }, }</script><style> .el-table th, .el-table td { text-align: center; }</style>

2.scoresColumn

<script> export default { data() { return { style: { ’min-width’: '70', ’resizable’: true, ’show-overflow-tooltip’: true }, } }, props: { column: { type: Object }, unitScores: { type: Object, default: () => {} } }, name: 'scoresColumn', render: function (h) { let scopedSlots = {default: (scope) => { let col = scope.column.property; let value = scope.row[col]; return <div id={col+scope.$index} > <p onClick={this.clickHandle}>{value}</p> </div>;} }; if (this.column.children === undefined)if (this.column.label == ’序號(hào)’ || this.column.label == ’姓名’) { return <el-table-column fixed {...{style: this.style, scopedSlots: {default: (scope) => { let value = scope.row[scope.column.property]; return <p>{value}</p>;} }}} prop={this.column.prop} label={this.column.label}> </el-table-column>}else { return <el-table-column {...{style: this.style, scopedSlots: {default: (scope) => { let value = scope.row[scope.column.property]; if (/((?=d)|(^總計(jì)$)/g.test(this.column.label)) { let col = scope.column.property; return <div id={col+scope.$index} > <p onClick={this.clickHandle}>{value}</p> </div>; }else return <p>{value}</p>;} }}} prop={this.column.prop} label={this.column.label}> </el-table-column>} let buildTitles = (childList) => {let children = [];childList.map(child => { if (child.children != undefined && child.children.length > 0) { children.push(<el-table-column {...{style: this.style}} label={child.label}> {buildTitles(child.children)} </el-table-column>) } else { children.push( <el-table-column {...{style: this.style, scopedSlots: scopedSlots}} label={child.label} prop={child.prop}> </el-table-column>) }});return children; }; return <el-table-column{...{style: this.style}}label={this.column.label}prop={this.column.prop}>{buildTitles(this.column.children)} </el-table-column>; }, methods: { blurHandler(e) {let parent = e.target.parentNode;let child = parent.firstElementChild;let p = document.createElement(’p’);let value = child.value.match(/^d*(.{1}d+)?/)[0];if (value == ’’ || value == null) { value = 0;}p.innerHTML = value;p.addEventListener(’click’, this.clickHandle, false);child.replaceWith(p);this.$emit(’dataChange’, parent.id); }, clickHandle(e) {let parent = e.target.parentNode;let child = parent.firstElementChild;let input = document.createElement(’input’);input.style.lineHeight = ’23px’;input.style.textAlign = ’center’;input.style.fontSize = ’12px’;input.style.height = ’23px’input.style.width = ’100%’;input.value = child.innerHTML;input.addEventListener(’blur’, this.blurHandler, true);input.addEventListener(’keyup’, this.keyUpHandler, false);child.replaceWith(input);input.focus(); }, keyUpHandler(e) {let input = e.target;let parent = input.parentNode;let property = parent.id.replace(/d/g, ’’);let value = input.value.replace(/[^d.]/g,’’);if (Math.min(this.unitScores[property],value) != value) { value = this.unitScores[property];}input.value = value; } } }</script><style scoped></style>

3.實(shí)現(xiàn)效果

vue+render+jsx實(shí)現(xiàn)可編輯動(dòng)態(tài)多級(jí)表頭table的實(shí)例代碼vue+render+jsx實(shí)現(xiàn)可編輯動(dòng)態(tài)多級(jí)表頭table的實(shí)例代碼

總結(jié)

到此這篇關(guān)于vue+render+jsx實(shí)現(xiàn)可編輯動(dòng)態(tài)多級(jí)表頭table的文章就介紹到這了,更多相關(guān)vue render jsx 多級(jí)表頭table內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 加勒比综合网 | 久9青青cao精品视频在线 | 久久免费精品 | 精品国产一区二区三区在线 | 亚洲视频中文 | 国产日韩精品视频一区二区三区 | 高清国产精品久久久久 | 国产精品三级a三级三级午夜 | 日本精品一在线观看视频 | 九色97| 一级毛片在线不卡直接观看 | 国产成年人在线观看 | 97青草香蕉依人在线播放 | 中国一级大黄大片 | 成人午夜免费观看 | 日本aa毛片a级毛片免费观看 | 久久久久久久久久久9精品视频 | 亚洲艹 | 国产孕妇孕交一级毛片 | 日本一视频一区视频二区 | 国产爽的冒白浆的视频高清 | 亚洲品质自拍视频网站 | 国内自拍视频在线播放 | 91精品久久久久久久久网影视 | 日韩精品观看 | 国产精品一区二区四区 | 久久精品视频久久 | 精品亚洲永久免费精品 | 97在线免费视频 | 国产一级高清 | 国产亚洲精品久久久久久无 | 精品一区二区三区四区在线 | 99久久精彩视频 | 亚洲专区欧美专区 | 精品午夜久久网成年网 | 欧美成网| 成人午夜免费在线观看 | 一级毛片免费播放视频 | 亚洲一级毛片免费观看 | a级片在线免费观看 | 欧美成人性动漫在线观看 |