From d0e206c501029b2b9889eb317f02bd772814e40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=81=8F?= Date: Thu, 1 Dec 2016 11:02:06 +0800 Subject: [PATCH] Table add content prop to compile custom component Table add content prop to compile custom component --- src/components/table/cell.vue | 7 +++-- src/components/table/table-head.vue | 2 +- src/components/table/table.vue | 34 +++++++++++--------- test/routers/table.vue | 48 +++++++++++++++++++---------- 4 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/components/table/cell.vue b/src/components/table/cell.vue index fa668920..ab92b721 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 8e9ce554..9b603441 100644 --- a/src/components/table/table-head.vue +++ b/src/components/table/table-head.vue @@ -34,7 +34,7 @@
-