成人视屏在线观看-国产99精品-国产精品1区2区-欧美一级在线观看-国产一区二区日韩-色九九九

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

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

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

最近項(xiàng)目需要實(shí)現(xiàn)可編輯的動(dòng)態(tài)多級(jí)表頭表格,看了兩天的文章,始終沒有找到我想要的效果,在了解了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)文章:
主站蜘蛛池模板: 国产成人精品免费视频软件 | 亚洲aa视频 | 免费久草 | 日韩免费视频播播 | 在线欧美精品一区二区三区 | 欧美亚洲午夜 | 国产精品久久精品视 | 性色网址| 国产在线精品福利91香蕉 | 亚洲线精品一区二区三区 | 亚洲国产成人最新精品资源 | 手机看片久久国产免费不卡 | 久久亚洲国产午夜精品理论片 | 99国产精品欧美久久久久久影院 | 久久精品人人爽人人爽快 | 成人毛片视频免费网站观看 | 国产精品亚洲二区在线 | 国产不卡毛片 | 在线中文 | 免看一级一片一在线看 | 爽死你个放荡粗暴小淫货双女视频 | 国产精品久久亚洲一区二区 | 国产高清在线观看视频手机版 | 性色欧美xo影院 | 一级欧美视频 | 国产精品久久久精品三级 | 中文字幕日韩精品有码视频 | 手机看片日韩日韩国产在线看 | 国产精品秦先生手机在线 | 男女无遮掩做爰免费视频软件 | 三级在线网站 | 国产一区二区三区精品久久呦 | 国产特黄特色的大片观看免费视频 | 美女视频网站永久免费观看软件 | 99久久精品国产免看国产一区 | 亚洲一级特黄特黄的大片 | 精品在线播放 | 三级全黄的视频 | 日韩欧美一级 | 欧美成人小视频 | 91九色精品国产免费 |