Meituan-Dianping/mpvue · error

v-${el.elseif ? ('else-if="' + el.elseif + '"') : 'else'} us

Error message

v-${el.elseif ? ('else-if="' + el.elseif + '"') : 'else'} used on element <${el.tag}> without corresponding v-if.

What it means

Dev-only warning in processIfConditions: a v-else / v-else-if element was found whose previous sibling in the parent's children is not a v-if element (or there is none). The conditional chain cannot be attached to anything, so the else block would render unconditionally; the compiler warns and treats the chain as broken.

Source

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

    if (getAndRemoveAttr(el, 'v-else') != null) {
      el.else = true
    }
    const elseif = getAndRemoveAttr(el, 'v-else-if')
    if (elseif) {
      el.elseif = elseif
    }
  }
}

function processIfConditions (el, parent) {
  const prev = findPrevElement(parent.children)
  if (prev && prev.if) {
    addIfCondition(prev, {
      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.`
        )
      }

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Ensure v-else/v-else-if immediately follows a v-if (or another v-else-if) element with no intervening element or v-if omission
  2. Remove the orphan v-else/v-else-if if the v-if was deleted
  3. Check that no wrapper element or comment-breaking element sits between them (plain whitespace text is tolerated only as single spaces)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/compiler/parser/index.js:382 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/b015853e8ddef2bb. Report an issue: GitHub.