table tr 的style.dispaly none 后 显示用''

本文讨论了在Internet Explorer (IE) 和Firefox (FF) 浏览器中使用inline样式显示不一致的问题。作者指出,在IE下使用inline显示正常,但在FF下则出现问题。解决方案是让FF自行处理布局,从而确保跨浏览器的一致性。

在ie下面使用inline是正常的.

但是ff却乱了.

所以,使用'',让ff来自己设置,就能正常显示了;

async function loadCart() { try { const response = await api.getCart(); const cartItems = response.data; const emptyMessage = document.getElementById('empty-cart-message'); const cartTable = document.getElementById('cart-items-table'); const cartActions = document.getElementById('cart-actions'); if (cartItems.length === 0) { emptyMessage.style.display = 'block'; cartTable.style.display = 'none'; cartActions.style.display = 'none'; return; } emptyMessage.style.display = 'none'; cartTable.style.display = 'table'; cartActions.style.display = 'block'; const tbody = document.getElementById('cart-items-body'); tbody.innerHTML = ''; let total = 0; cartItems.forEach(item => { const subtotal = item.quantity * item.product.price; total += subtotal; const row = document.createElement('tr'); row.dataset.cartId = item.cartId; row.innerHTML = ` <td> <img src="${item.product.image_url || 'images/placeholder.jpg'}" alt="${item.product.name}" width="50"> ${item.product.name} </td> <td>¥${item.product.price.toFixed(2)}</td> <td> <input type="number" value="${item.quantity}" min="1" onchange="updateCartItem(${item.cartId}, this.value)"> </td> <td>¥${subtotal.toFixed(2)}</td> <td> <button class="btn btn-danger" onclick="removeFromCart(${item.cartId})">删除</button> </td> `; tbody.appendChild(row); }); document.getElementById('cart-total').textContent = `¥${total.toFixed(2)}`; } catch (error) { console.error('载购物车失败:', error); alert('载购物车失败: ' + error.message); } }修改该部分
09-07
exportTableToExcel(tableId, filename) { // 获取表格DOM const table = document.getElementById(tableId); if (!table) { console.error('表格元素不存在'); return; } // 处理分页数据 const originalPageSize = this.pagination.pageSize; this.pagination.pageSize = this.pagination.total; // 显示所有数据 this.pagination.page = 1; console.log(this.pagination, originalPageSize, this.pagination.total) this.$nextTick(() => { // 处理固定列问题 const fixed = table.querySelector('.el-table__fixed'); console.log(fixed, 'fff') if (fixed) { table.removeChild(fixed); } // 隐藏第一列多选框 // 1. 隐藏多选列(表头和主体) const selectionTh = table.querySelector('.el-table-column--selection'); const selectionTds = table.querySelectorAll('td.el-table-column--selection'); const originalDisplay = []; if (selectionTh) { selectionTh.style.display = 'none'; // 隐藏表头 } selectionTds.forEach(td => td.style.display = 'none'); // 隐藏主体单元格 // const selectionTds = table.querySelectorAll('td.el-table-column--selection'); // selectionTds.forEach(td => { // table.removeChild(td); // }); // 创建工作簿 console.log(XLSX, table) const workbook = XLSX.utils.table_to_book(table); if (fixed) { table.appendChild(fixed); // 恢复固定列 } // 恢复多选列原始显示状态 if (selectionTh) { selectionTh.style.display = ''; // 恢复表头 } selectionTds.forEach(td => td.style.display = ''); // 恢复主体单元格 if (fixed) { fixed.style.display = ''; // 恢复固定列 } // 导出Excel const wbout = XLSX.write(workbook, { bookType: 'xlsx', bookSST: true, type: 'array' }); FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename + '.xlsx'); // 恢复分页状态 this.pagination.pageSize = originalPageSize; this.pagination.page = 1; }); }, 优化此代码,导出文件去掉第一列多选框列
最新发布
12-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值