Vuejs shorthand for conditional rendering

Viewed 51

In Laravel I can use this shorthand:

{{ $my_variable ?? '-' }}

Instead:

{{ ($my_variable) ? $my_variable : '-' }}

Is there an equivalent in VueJS?

I'm doing this so far:

@{{ (my_var) ? my_var : '-' }}
1 Answers

You could use or logical operator || :

@{{ my_var || '-' }}
Related