I have a little Loading component, whose default text I want to be 'Loading...'. Good candidate for slots, so I have something like this as my template:
<p class="loading"><i class="fa fa-spinner fa-spin"></i><slot>Loading...</slot></p>
That allows me to change the loading message with e.g. <loading>Searching...</loading>
. The behaviour I would like, though, is not just to display the default message if no slot content is supplied, but also if the slot content is null or blank. At the moment if I do e.g.<loading>{{loadingMessage}}</loading>
and loadingMessage is null, no text is displayed (where I want the default text to be displayed). So ideally I need to test this.$slots.default
. This tells me whether content was passed in, but how do I find whether or not it was empty? this.$slots.default.text
returns undefined.