Meituan-Dianping/mpvue · error

text "${children[i].text.trim()}" between v-if and v-else(-i

Error message

text "${children[i].text.trim()}" between v-if and v-else(-if) will be ignored.

What it means

Dev-only warning from findPrevElement while resolving v-if/v-else chains: non-element nodes (text/interpolation) exist between a v-if element and its v-else/v-else-if sibling. The compiler still links the chain but discards that text, so content silently disappears from output.

Source

Thrown at src/compiler/parser/index.js:396

      exp: el.elseif,
      block: el
    })
  } else if (process.env.NODE_ENV !== 'production') {
    warn(
      `v-${el.elseif ? ('else-if="' + el.elseif + '"') : 'else'} ` +
      `used on element <${el.tag}> without corresponding v-if.`
    )
  }
}

function findPrevElement (children: Array<any>): ASTElement | void {
  let i = children.length
  while (i--) {
    if (children[i].type === 1) {
      return children[i]
    } else {
      if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
        warn(
          `text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
          `will be ignored.`
        )
      }
      children.pop()
    }
  }
}

function addIfCondition (el, condition) {
  if (!el.ifConditions) {
    el.ifConditions = []
  }
  el.ifConditions.push(condition)
}

function processOnce (el) {
  const once = getAndRemoveAttr(el, 'v-once')

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Remove the text between the v-if and v-else(-if) elements
  2. Move the text inside one of the conditional branches
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/compiler/parser/index.js:396 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02). Data as JSON: /api/errors/8494b592565497b3. Report an issue: GitHub.