Commit 87a400d85ecef1ebcc29583199ff272fa82c4218
1 parent
c0b2524d
update Table
update Table
Showing
1 changed file
with
10 additions
and
10 deletions
Show diff stats
src/components/table/cell.vue
| 1 | 1 | <template> |
| 2 | - <div :class="classes"> | |
| 2 | + <div :class="classes" ref="cell"> | |
| 3 | 3 | <template v-if="renderType === 'index'">{{naturalIndex + 1}}</template> |
| 4 | 4 | <template v-if="renderType === 'selection'"> |
| 5 | 5 | <Checkbox :value="checked" @on-change="toggleSelect" :disabled="disabled"></Checkbox> |
| ... | ... | @@ -52,27 +52,27 @@ |
| 52 | 52 | const template = this.column.render(this.row, this.column, this.index); |
| 53 | 53 | const cell = document.createElement('div'); |
| 54 | 54 | cell.innerHTML = template; |
| 55 | - const _oldParentChildLen = $parent.$children.length; | |
| 56 | - // $parent.$compile(cell); // todo 这里无法触发 ready 钩子 | |
| 57 | - const _newParentChildLen = $parent.$children.length; | |
| 58 | - if (_oldParentChildLen !== _newParentChildLen) { // if render normal html node, do not tag | |
| 59 | - this.uid = $parent.$children[$parent.$children.length - 1]._uid; // tag it, and delete when data or columns update | |
| 60 | - } | |
| 55 | +// const _oldParentChildLen = $parent.$children.length; | |
| 56 | +// const _newParentChildLen = $parent.$children.length; | |
| 57 | +// if (_oldParentChildLen !== _newParentChildLen) { // if render normal html node, do not tag | |
| 58 | +// this.uid = $parent.$children[$parent.$children.length - 1]._uid; // tag it, and delete when data or columns update | |
| 59 | +// } | |
| 61 | 60 | this.$el.innerHTML = ''; |
| 62 | 61 | let methods = {}; |
| 63 | 62 | Object.keys($parent).forEach(key => { |
| 64 | 63 | const func = this.$parent.$parent.$parent[`${key}`]; |
| 65 | - if(typeof(func) === 'function' &&func.name === 'boundFn'){ | |
| 64 | + if (typeof(func) === 'function' && func.name === 'boundFn') { | |
| 66 | 65 | methods[`${key}`] = func; |
| 67 | 66 | } |
| 68 | 67 | }); |
| 69 | 68 | const res = Vue.compile(cell.outerHTML); |
| 70 | - const compt = new Vue({ | |
| 69 | + const component = new Vue({ | |
| 71 | 70 | render: res.render, |
| 72 | 71 | staticRenderFns: res.staticRenderFns, |
| 73 | 72 | methods: methods |
| 74 | 73 | }); |
| 75 | - compt.$mount(this.$el); | |
| 74 | + const Cell = component.$mount(); | |
| 75 | + this.$refs.cell.appendChild(Cell.$el); | |
| 76 | 76 | } |
| 77 | 77 | }, |
| 78 | 78 | destroy () { | ... | ... |