Posts

Showing posts with the label vue-component

How get component instance from unnamed slots on Vue.js2

How get component instance from unnamed slots on Vue.js2 I have next template: <TableComponent> <TableColumn v-bind:field="'firstName'" v-bind:label="'First Name"> </TableColumn> How i can get component instances of TableColumn ? TableColumn On TableComponent I have next mounted method: mounted mounted () { const columnComponents = this.$slots.default .filter(column => column.componentInstance) .map(column => column.componentInstance) console.info(columnComponents) }, But on console info I got empty array. How I can get TableColumn props? TableColumn 1 Answer 1 Use a ref ref <TableComponent> <TableColumn ref="tableColumn" v-bind:field="'firstName'" v-bind:label="'First Name"> </TableColumn> and then mounted() { this.$nextTick(() => { const col =...