A
A
Alexey Nikolaev2019-10-03 01:32:48
Vue.js
Alexey Nikolaev, 2019-10-03 01:32:48

Are conditional slots possible?

Goodnight.
I want to render a slot if and only if one of the properties (item in the table) will have child entities (I'm making a tree table). Actually, the problem is that I need to get the data that is transferred to the slot, and based on this data, perform a check. But it doesn't work like that, Vue writes that item is not defined.

<v-data-table>
   <template v-if="check(item)" v-slot:item.data-table-expand="{ item }">
      <span >test</span>
    </template>
</v-data-table>

At the same time, transferring the condition to the body of the slot does not give what I want at all. I need my content to be shown under certain conditions, and defaulted under all other conditions. I also tried to find a way to get (or somehow force the use of) this very default content - I did not find such a feature. Although earlier, as I can tell by stack overflow, conditional slots worked - the old syntax with slot-scope allowed. The new syntax apparently no longer allows.
Is it possible to implement this, and if so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chakaponi, 2019-10-03
@chakaponi

Perhaps this will help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question