Skip to content

Commit

Permalink
Fix detail
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglisky committed Oct 26, 2017
1 parent 663aa03 commit a5d8cd5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<template slot="expand" slot-scope="{ row }">
<section class="expand-detail">
<div v-for="col in columns" :key="col.label">
{{ col.label }}:{{ row[col.prop] }}
{{ col.name }}:{{ row[col.prop] }}
</div>
</section>
</template>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "egrid",
"description": "element-ui table packaging",
"version": "1.0.1",
"version": "1.0.2",
"author": "芊野 <free.nan.sky@gmail.com>",
"private": false,
"repository": {
Expand Down
18 changes: 8 additions & 10 deletions src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
v-bind="tableBind"
v-on="$listeners">
<template v-for="tp in columnTypes">
<el-table-column :key="tp" type="expand" v-if="tp === 'expand'">
<el-table-column v-if="tp === 'expand'" type="expand" :key="tp">
<template slot-scope="props">
<slot name="expand" v-bind="props"></slot>
</template>
</el-table-column>
<el-table-column :key="tp" v-else :type="tp"></el-table-column>
<el-table-column v-else :type="tp" :key="tp"></el-table-column>
</template>
<el-table-column v-for="col in renderColumns"
:key="col.label" v-bind="getColBind(col)">
Expand Down Expand Up @@ -46,6 +46,8 @@ const COLUMN_PROPS = {
component: Text
}
const TYPES = ['selection', 'expand', 'index']
const COLUMN_KEY_MAP = {
label: 'label',
prop: 'prop'
Expand Down Expand Up @@ -87,11 +89,7 @@ export default {
},
computed: {
showSelectionIndex () {
return this.columnType === 'selection' || this.columnType === 'index'
},
// 处理 $attrs 里面 Boolean 类型的 prop 和,统一 prop 命名
// 处理 $attrs 里面 Boolean 类型的 prop 和统一 prop 命名
tableBind () {
const { $attrs } = this
const bind = {}
Expand Down Expand Up @@ -123,12 +121,12 @@ export default {
},
columnTypes () {
const type = this.columnType
const { columnType: type } = this
if (!type) return []
if (typeof type === 'string') {
if (typeof type === 'string' && ~TYPES.indexOf(type)) {
return [type]
}
return Array.isArray(type) ? type : []
return Array.isArray(type) && type.filter(it => ~TYPES.indexOf(it)) || []
}
},
Expand Down

0 comments on commit a5d8cd5

Please sign in to comment.