May 18, 2021
Per Djurner

Nullish coalescing operator in Vue templates

The nullish coalescing operator can be really useful when you want to display, for example, "N/A" when a value is null or undefined, but not when it's 0.

  <p>{{ val ?? 'N/A' }}</p>

export default {
  data() {
    return {
      val: 0

Note that you need Vue 3 for this to work in templates.