parent
55ea6412dc
commit
8d97214424
6 changed files with 303 additions and 0 deletions
@ -0,0 +1,43 @@ |
||||
<template> |
||||
<el-table :data="tableData" style="width: 80%;"> |
||||
<el-table-column prop="date" label="Date" fixed width="180"></el-table-column> |
||||
<el-table-column prop="name" label="Name" width="2500"></el-table-column> |
||||
<el-table-column prop="address" label="Address" fixed="right" width="300"></el-table-column> |
||||
</el-table> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
name: "Table_Demo6", |
||||
data() { |
||||
return { |
||||
tableData: [ |
||||
{ |
||||
date: "2016-05-03", |
||||
name: "Tom", |
||||
address: "No. 189, Grove St, Los Angeles" |
||||
}, |
||||
{ |
||||
date: "2016-05-04", |
||||
name: "Tom1", |
||||
address: "No. 1891, Grove St, Los Angeles" |
||||
}, |
||||
{ |
||||
date: "2016-05-05", |
||||
name: "Tom2", |
||||
address: "No. 1892, Grove St, Los Angeles" |
||||
}, |
||||
{ |
||||
date: "2016-05-06", |
||||
name: "Tom3", |
||||
address: "No. 1893, Grove St, Los Angeles" |
||||
}, |
||||
] |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,66 @@ |
||||
<template> |
||||
<el-table :data="tableData" > |
||||
<el-table-column prop="date" label="Date" width="150"></el-table-column> |
||||
<el-table-column label="Delivery info"> |
||||
<el-table-column prop="name" label="Name" width="150"></el-table-column> |
||||
<el-table-column label="Address info"> |
||||
<el-table-column prop="state" label="State" width="150"></el-table-column> |
||||
<el-table-column prop="city" label="City" width="150"></el-table-column> |
||||
<el-table-column prop="address" label="Address" width="300"></el-table-column> |
||||
<el-table-column prop="zip" label="Zip" width="150"></el-table-column> |
||||
</el-table-column> |
||||
</el-table-column> |
||||
</el-table> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
name: "Table_Demo7", |
||||
data() { |
||||
return { |
||||
tableData: [ |
||||
{ |
||||
date: '2016-05-03', |
||||
name: 'Tom', |
||||
state: 'California', |
||||
city: 'Los Angeles', |
||||
address: 'No. 189, Grove St, Los Angeles', |
||||
zip: 'CA 90036', |
||||
tag: 'Home', |
||||
}, |
||||
{ |
||||
date: '2016-05-02', |
||||
name: 'Tom', |
||||
state: 'California', |
||||
city: 'Los Angeles', |
||||
address: 'No. 189, Grove St, Los Angeles', |
||||
zip: 'CA 90036', |
||||
tag: 'Office', |
||||
}, |
||||
{ |
||||
date: '2016-05-04', |
||||
name: 'Tom', |
||||
state: 'California', |
||||
city: 'Los Angeles', |
||||
address: 'No. 189, Grove St, Los Angeles', |
||||
zip: 'CA 90036', |
||||
tag: 'Home', |
||||
}, |
||||
{ |
||||
date: '2016-05-01', |
||||
name: 'Tom', |
||||
state: 'California', |
||||
city: 'Los Angeles', |
||||
address: 'No. 189, Grove St, Los Angeles', |
||||
zip: 'CA 90036', |
||||
tag: 'Office', |
||||
}, |
||||
] |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,87 @@ |
||||
<template> |
||||
<el-table :data="tableData" :span-method="arraySpanMethod" border> |
||||
<el-table-column prop="id" label="ID" width="180"></el-table-column> |
||||
<el-table-column prop="name" label="Name"></el-table-column> |
||||
<el-table-column prop="amount1" sortable label="Amount1"></el-table-column> |
||||
<el-table-column prop="amount2" sortable label="Amount2"></el-table-column> |
||||
<el-table-column prop="amount3" sortable label="Amount3"></el-table-column> |
||||
</el-table> |
||||
<br> |
||||
<el-table :data="tableData" :span-method="objectSpanMethod" border> |
||||
<el-table-column prop="id" label="ID" width="180"></el-table-column> |
||||
<el-table-column prop="name" label="Name"></el-table-column> |
||||
<el-table-column prop="amount1" sortable label="Amount1"></el-table-column> |
||||
<el-table-column prop="amount2" sortable label="Amount2"></el-table-column> |
||||
<el-table-column prop="amount3" sortable label="Amount3"></el-table-column> |
||||
</el-table> |
||||
</template> |
||||
<script> |
||||
export default { |
||||
name: "Table_Demo8", |
||||
data() { |
||||
return { |
||||
tableData: [ |
||||
{ |
||||
id: '12987122', |
||||
name: 'Tom', |
||||
amount1: '234', |
||||
amount2: '3.2', |
||||
amount3: 10, |
||||
}, |
||||
{ |
||||
id: '12987123', |
||||
name: 'Tom', |
||||
amount1: '165', |
||||
amount2: '4.43', |
||||
amount3: 12, |
||||
}, |
||||
{ |
||||
id: '12987124', |
||||
name: 'Tom', |
||||
amount1: '324', |
||||
amount2: '1.9', |
||||
amount3: 9, |
||||
}, |
||||
{ |
||||
id: '12987125', |
||||
name: 'Tom', |
||||
amount1: '621', |
||||
amount2: '2.2', |
||||
amount3: 17, |
||||
}, |
||||
{ |
||||
id: '12987126', |
||||
name: 'Tom', |
||||
amount1: '539', |
||||
amount2: '4.1', |
||||
amount3: 15, |
||||
}, |
||||
] |
||||
} |
||||
}, |
||||
methods: { |
||||
arraySpanMethod({row, column, rowIndex, columnIndex}) { |
||||
if (rowIndex % 2 === 0) { |
||||
if (columnIndex === 0) { |
||||
return [1, 2] // columnIndex === 0 表示第一列,[1, 2] 1代表行不合并,2代表列占用2列 |
||||
} else if (columnIndex === 1) { |
||||
return [0, 0] // 由于第一列占用了两列,所以第二列的内容需要设置为[0,0]就不会占空间了 |
||||
} |
||||
} |
||||
}, |
||||
objectSpanMethod({row, column, rowIndex, columnIndex}) { |
||||
if (columnIndex === 0) { |
||||
if (rowIndex % 2 === 0) { |
||||
return [2, 1] |
||||
} else if (rowIndex % 2 === 1) { |
||||
return [0, 0] |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,79 @@ |
||||
<template> |
||||
<el-table :data="tableData" :row-class-name="rowClassMethod"> |
||||
<el-table-column prop="id" label="Id"></el-table-column> |
||||
<el-table-column prop="name" label="Name"></el-table-column> |
||||
<el-table-column prop="score" label="Score"></el-table-column> |
||||
</el-table> |
||||
</template> |
||||
|
||||
<script> |
||||
|
||||
export default { |
||||
name: "Table_Demo9", |
||||
data() { |
||||
return { |
||||
tableData: [ |
||||
{ |
||||
id: '12987122', |
||||
name: 'Tom', |
||||
score: '99' |
||||
}, |
||||
{ |
||||
id: '12987123', |
||||
name: 'black', |
||||
score: '81' |
||||
}, |
||||
{ |
||||
id: '12987124', |
||||
name: 'harry', |
||||
score: '70' |
||||
}, |
||||
{ |
||||
id: '12987125', |
||||
name: 'Jerry', |
||||
score: '58' |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
methods: { |
||||
rowClassMethod(e) { |
||||
console.log(e); |
||||
const {row} = e; |
||||
let rowClassName = ""; |
||||
const score = row.score; |
||||
console.log(score) |
||||
if (score >= 85) { |
||||
console.log(1) |
||||
rowClassName = "excellent" |
||||
} else if (score > 75) { |
||||
console.log(2) |
||||
rowClassName = "good" |
||||
} else if (score > 65) { |
||||
rowClassName = "normal" |
||||
} else { |
||||
rowClassName = "bad" |
||||
} |
||||
return rowClassName |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
.el-table :deep(.excellent) { |
||||
background-color: darkorange; |
||||
} |
||||
|
||||
.el-table :deep(.good) { |
||||
background-color: cornflowerblue; |
||||
} |
||||
|
||||
.el-table :deep(.normal) { |
||||
background-color: aliceblue; |
||||
} |
||||
|
||||
.el-table :deep(.bad) { |
||||
background-color: #ff6666; |
||||
} |
||||
</style> |
Loading…
Reference in new issue