Meituan-Dianping/mpvue · error

Invalid v-for expression: ${exp}

Error message

Invalid v-for expression: ${exp}

What it means

Dev-only warning in processFor: the v-for attribute value did not match forAliasRE, the pattern requiring 'alias in expression' (optionally with iterators). Without that structure the compiler cannot extract the iterable and alias, so the directive is skipped and the list will not render.

Source

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

    }
    el.key = exp
  }
}

function processRef (el) {
  const ref = getBindingAttr(el, 'ref')
  if (ref) {
    el.ref = ref
    el.refInFor = checkInFor(el)
  }
}

function processFor (el) {
  let exp
  if ((exp = getAndRemoveAttr(el, 'v-for'))) {
    const inMatch = exp.match(forAliasRE)
    if (!inMatch) {
      process.env.NODE_ENV !== 'production' && warn(
        `Invalid v-for expression: ${exp}`
      )
      return
    }
    el.for = inMatch[2].trim()
    const alias = inMatch[1].trim()
    const iteratorMatch = alias.match(forIteratorRE)
    if (iteratorMatch) {
      el.alias = iteratorMatch[1].trim()
      el.iterator1 = iteratorMatch[2].trim()
      if (iteratorMatch[3]) {
        el.iterator2 = iteratorMatch[3].trim()
      }
    } else {
      el.alias = alias
    }
  }
}

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Rewrite v-for in 'item in items' (or '(item, index) in items') form
  2. Remove stray characters or newlines breaking the expression
  3. Use v-for="(value, key) in object" for objects
Defensive patterns

Strategy: validation

When it happens

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