Commit 87a400d85ecef1ebcc29583199ff272fa82c4218

Authored by 梁灏
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 <template> 1 <template>
2 - <div :class="classes"> 2 + <div :class="classes" ref="cell">
3 <template v-if="renderType === 'index'">{{naturalIndex + 1}}</template> 3 <template v-if="renderType === 'index'">{{naturalIndex + 1}}</template>
4 <template v-if="renderType === 'selection'"> 4 <template v-if="renderType === 'selection'">
5 <Checkbox :value="checked" @on-change="toggleSelect" :disabled="disabled"></Checkbox> 5 <Checkbox :value="checked" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 const template = this.column.render(this.row, this.column, this.index); 52 const template = this.column.render(this.row, this.column, this.index);
53 const cell = document.createElement('div'); 53 const cell = document.createElement('div');
54 cell.innerHTML = template; 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 this.$el.innerHTML = ''; 60 this.$el.innerHTML = '';
62 let methods = {}; 61 let methods = {};
63 Object.keys($parent).forEach(key => { 62 Object.keys($parent).forEach(key => {
64 const func = this.$parent.$parent.$parent[`${key}`]; 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 methods[`${key}`] = func; 65 methods[`${key}`] = func;
67 } 66 }
68 }); 67 });
69 const res = Vue.compile(cell.outerHTML); 68 const res = Vue.compile(cell.outerHTML);
70 - const compt = new Vue({ 69 + const component = new Vue({
71 render: res.render, 70 render: res.render,
72 staticRenderFns: res.staticRenderFns, 71 staticRenderFns: res.staticRenderFns,
73 methods: methods 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 destroy () { 78 destroy () {