-
This commit is contained in:
parent
b8adf5cf2d
commit
718e773fbc
5 changed files with 33 additions and 39 deletions
16
examples/components/tableExpand.vue
Executable file
16
examples/components/tableExpand.vue
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
<template>
|
||||||
|
<div>{{ name }}</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
name: String
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
console.log(this.name + ': 被创建');
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
console.log(this.name + ': 被销毁');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -2,6 +2,7 @@
|
||||||
<Table border :columns="columns7" :data="data6" @on-expand="expand"></Table>
|
<Table border :columns="columns7" :data="data6" @on-expand="expand"></Table>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import TableExpand from '../components/tableExpand.vue';
|
||||||
import etable from '../components/table.vue';
|
import etable from '../components/table.vue';
|
||||||
export default {
|
export default {
|
||||||
components: { etable },
|
components: { etable },
|
||||||
|
@ -13,7 +14,8 @@
|
||||||
width: 50,
|
width: 50,
|
||||||
render: (h, params) => {
|
render: (h, params) => {
|
||||||
// return h(etable);
|
// return h(etable);
|
||||||
return h('div', params.row.name)
|
// return h('div', params.row.name)
|
||||||
|
return h(TableExpand, { props: { name: params.row.name } })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
13
src/components/table/expand.js
Normal file
13
src/components/table/expand.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'TableExpand',
|
||||||
|
functional: true,
|
||||||
|
props: {
|
||||||
|
row: Object,
|
||||||
|
render: Function,
|
||||||
|
index: Number,
|
||||||
|
},
|
||||||
|
render: (h, ctx) => {
|
||||||
|
return ctx.props.render(h, {row: ctx.props.row, index: ctx.props.index});
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,37 +0,0 @@
|
||||||
<template>
|
|
||||||
<div ref="cell"></div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import Vue from 'vue';
|
|
||||||
export default {
|
|
||||||
name: 'TableExpand',
|
|
||||||
props: {
|
|
||||||
row: Object,
|
|
||||||
render: Function,
|
|
||||||
index: Number,
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
compile () {
|
|
||||||
if (this.render) {
|
|
||||||
this.$el.innerHTML = '';
|
|
||||||
const component = new Vue({
|
|
||||||
functional: true,
|
|
||||||
render: (h) => {
|
|
||||||
return this.render(h, {
|
|
||||||
row: this.row,
|
|
||||||
index: this.index
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const Cell = component.$mount();
|
|
||||||
this.$refs.cell.appendChild(Cell.$el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.compile();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
|
@ -38,7 +38,7 @@
|
||||||
<script>
|
<script>
|
||||||
// todo :key="row"
|
// todo :key="row"
|
||||||
import Cell from './cell.vue';
|
import Cell from './cell.vue';
|
||||||
import Expand from './expand.vue';
|
import Expand from './expand.js';
|
||||||
import Mixin from './mixin';
|
import Mixin from './mixin';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
Loading…
Add table
Reference in a new issue