实现一个竖直的显示表头的表格(vue版本)
<template>
<table class="mailTable" :style="styleObject" v-if="s_showByRow">
<tr v-for="index in rowCount">
<td class="column">{{tableData[index*2-2].key}}</td>
<td>{{tableData[index*2-2].value}}</td>
<td class="column">{{tableData[index*2-1] !== undefined ? tableData[index*2-1].key : ''}}</td>
<td>{{tableData[index*2-1] !== undefined ? tableData[index*2-1].value : ''}}</td>
</tr>
</table>
<table class="mailTable" :style="styleObject" v-else>
<tr v-for="index in rowCount">
<td class="column">{{tableData[index-1].key}}</td>
<td>{{tableData[index-1].value}}</td>
<td class="column">{{tableData[rowCount+index-1] !== undefined ? tableData[rowCount+index-1].key : ''}}</td>
<td>{{tableData[rowCount+index-1] !== undefined ? tableData[rowCount+index-1].value : ''}}</td>
</tr>
</table>
</template> <script>
export default {
data() {
return {
styleObject: {},
s_showByRow: true,
};
},
props: ['tableData', 'tableStyle', 'showByRow'],
computed: {
rowCount: function() {
return Math.ceil(this.tableData.length/2);
}
},
created() {
this.styleObject = this.tableStyle;
if(this.showByRow !== undefined){
this.s_showByRow = this.showByRow;
}
},
}
</script>
补充css:
<style>
.mailTable, .mailTable tr, .mailTable tr td{ border:1px solid #E6EAEE; }
.mailTable{ font-size: 12px; color: #71787E; }
.mailTable tr td{ border:1px solid #E6EAEE; width: 150px; height: 35px; line-height: 35px; box-sizing: border-box; padding: 0 10px; }
.mailTable tr td.column { background-color: #EFF3F6; color: #393C3E; }
</style>
<mailTable :tableData="tableData" :tableStyle="{ width:'600px' }"></mailTable>
tableData: [
{key: '单号', value: '1001'},
{key: '商品名称', value: '篮球'},
{key: '价格', value: '120.00'},
{key: '订单日期', value: '2017-03-01'},
{key: '付款方式', value: '在线支付'},
{key: '收货地址', value: '北京市海淀区西北旺镇'},
],
实现一个竖直的显示表头的表格(vue版本)的更多相关文章
- css控制竖直文字显示
假如有一天,你把水平文字看腻味了...... 我建议你不妨试试垂直文字显示,就像这样: 我 是 竖 直 显 示 的 : 哈哈! 言归正传,怎么把一段话,垂直显示呢? 方法1: //把下面代码另存为ht ...
- Winform中设置ZedGraph因设置小刻度导致的竖直虚线显示过多
场景 Winforn中设置ZedGraph曲线图的属性.坐标轴属性.刻度属性: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...
- input竖直的输入框,文字从上到下排列
有的时候可能会有这样的需求,一个竖直的输入框,输入信息,文字也是从上到下排列: (但是在移动端或用轮播swiper时不起作用,可以用textarea代替input) <!DOCTYPE html ...
- PyQt学习随笔:QTableWidget水平表头horizontalHeader、竖直表头verticalHeader的相关操作方法
老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 QTableWidget表格部件的表头包括水平表头和竖直表头,水平表头每节对应表格的一列,竖直表头对 ...
- CollectionView水平和竖直瀑布流的实现
最近在项目中需要实现一个水平的瀑布流(即每个Cell的高度是固定的,但是长度是不固定的),因为需要重写系统 UICollectionViewLayout中的一些方法通过计算去实现手动布局,所以本着代码 ...
- HTML中行内元素的竖直方向的padding和margin是否真的无效
参考资料:Inline elements and padding 今天写一个导航栏时遇到了一个问题:行内元素的padding-top,padding-bottom和margin-top,margin- ...
- [LeetCode] Binary Tree Vertical Order Traversal 二叉树的竖直遍历
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...
- SSRS(rdl报表)分页显示表头和对表头的冻结处理
基础环境 最近在公司做西门子某系统的二次开发,需要用到SQLServer Reporting Services(SSRS).我们用的SQL版本是SQLServer 2008 R2:在设计报表时,表格用 ...
- 仿腾讯QQ竖直滑动导航菜单
菜单就像qq软件的分组,鼠标经过自动显示相应组的内容. 效果体验网址:http://keleyi.com/a/bjad/nf86w2dv.htm 以下是源代码: <html> <he ...
随机推荐
- Log日志规范
Overview 一个在生产环境里运行的程序如果没有日志是很让维护者提心吊胆的,有太多杂乱又无意义的日志也是令人伤神.程序出现问题时候,从日志里如果发现不了问题可能的原因是很令人受挫的.本文想讨论的是 ...
- 【转】Nutch的Hadoop方式爬取效率优化
原文地址:http://my.oschina.net/junfrank/blog/290404
- MYSQL中添加时间
1.在创建新记录和修改现有记录的时候都对这个数据列刷新:TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 2.在创建新记录 ...
- NodeJS链接MongDB
创建一个mongdb.js var mongodb = require('mongodb') // 创建数据库服务的链接 var server = new mongodb.Server( 'local ...
- Linux实战教学笔记21:Rsync数据同步工具
第二十一节 Rsync数据同步工具 标签(空格分隔): Linux实战教学笔记-陈思齐 ---本教学笔记是本人学习和工作生涯中的摘记整理而成,此为初稿(尚有诸多不完善之处),为原创作品,允许转载,转载 ...
- 网络传入安全jwts
使用json web token 发表于Aug 13 2014 由来 做了这么长时间的web开发,从JAVA EE中的jsf,spring,hibernate框架,到spring web MVC,到用 ...
- 1688: [Usaco2005 Open]Disease Manangement 疾病管理
1688: [Usaco2005 Open]Disease Manangement 疾病管理 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 413 So ...
- 读书笔记 effective c++ Item 32 确保public继承建立“is-a”模型
1. 何为public继承的”is-a”关系 在C++面向对象准则中最重要的准则是:public继承意味着“is-a”.记住这个准则. 如果你实现一个类D(derived)public继承自类B(ba ...
- TensorBoard:Visualizing Learning 学习笔记
为了更方便的理解.调试和优化TF程序,我们可以使用TensorBoard(可视化工具).可以使用TensorBoard查看graph,绘制图表执行过程中的定量指标.TensorBoard是完全可配置的 ...
- Effective Modern C++ Item 27:重载universal references
假设有一个接收universal references的模板函数foo,定义如下: template<typename T> void foo(T&& t) { cout ...