diff --git a/src/components/table/cell.vue b/src/components/table/cell.vue
index fa66892..ab92b72 100644
--- a/src/components/table/cell.vue
+++ b/src/components/table/cell.vue
@@ -27,7 +27,8 @@
data () {
return {
renderType: '',
- uid: -1
+ uid: -1,
+ content: this.$parent.$parent.content
}
},
computed: {
@@ -43,7 +44,7 @@
methods: {
compile () {
if (this.column.render) {
- const $parent = this.$parent.$parent.$parent;
+ const $parent = this.content;
const template = this.column.render(this.row, this.column, this.index);
const cell = document.createElement('div');
cell.innerHTML = template;
@@ -59,7 +60,7 @@
}
},
destroy () {
- const $parent = this.$parent.$parent.$parent;
+ const $parent = this.content;
for (let i = 0; i < $parent.$children.length; i++) {
if ($parent.$children[i]._uid === this.uid) {
$parent.$children[i].$destroy();
diff --git a/src/components/table/table-head.vue b/src/components/table/table-head.vue
index 8e9ce55..9b60344 100644
--- a/src/components/table/table-head.vue
+++ b/src/components/table/table-head.vue
@@ -34,7 +34,7 @@
-
+
- 全部
diff --git a/src/components/table/table.vue b/src/components/table/table.vue
index 2a7d5ca..eb9574e 100644
--- a/src/components/table/table.vue
+++ b/src/components/table/table.vue
@@ -122,6 +122,9 @@
default () {
return '';
}
+ },
+ content: {
+ type: Object
}
},
data () {
@@ -243,23 +246,25 @@
let autoWidthIndex = -1;
if (allWidth) autoWidthIndex = this.cloneColumns.findIndex(cell => !cell.width);//todo 这行可能有问题
- const $td = this.$refs.tbody.$el.querySelectorAll('tbody tr')[0].querySelectorAll('td');
- for (let i = 0; i < $td.length; i++) { // can not use forEach in Firefox
- const column = this.cloneColumns[i];
+ if (this.data.length) {
+ const $td = this.$refs.tbody.$el.querySelectorAll('tbody tr')[0].querySelectorAll('td');
+ for (let i = 0; i < $td.length; i++) { // can not use forEach in Firefox
+ const column = this.cloneColumns[i];
- let width = parseInt(getStyle($td[i], 'width'));
- if (i === autoWidthIndex) {
- width = parseInt(getStyle($td[i], 'width')) - 1;
- }
- if (column.width) width = column.width;
+ let width = parseInt(getStyle($td[i], 'width'));
+ if (i === autoWidthIndex) {
+ width = parseInt(getStyle($td[i], 'width')) - 1;
+ }
+ if (column.width) width = column.width;
- this.cloneColumns[i]._width = width;
+ this.cloneColumns[i]._width = width;
- columnsWidth[column._index] = {
- width: width
+ columnsWidth[column._index] = {
+ width: width
+ }
}
+ this.columnsWidth = columnsWidth;
}
- this.columnsWidth = columnsWidth;
});
});
},
@@ -502,6 +507,7 @@
}
},
compiled () {
+ if (!this.content) this.content = this.$parent;
this.showSlotHeader = this.$els.title.innerHTML.replace(/\n/g, '').replace(//gmi, '') !== '';
this.showSlotFooter = this.$els.footer.innerHTML.replace(/\n/g, '').replace(//gmi, '') !== '';
this.rebuildData = this.makeDataWithSortAndFilter();
diff --git a/test/routers/table.vue b/test/routers/table.vue
index 9cde164..06bfb50 100644
--- a/test/routers/table.vue
+++ b/test/routers/table.vue
@@ -1,27 +1,38 @@
-
+
+
+
\ No newline at end of file
+
--
libgit2 0.21.4