{"record":{"id":"4ddf7f9930886a4b","repo":"Meituan-Dianping/mpvue","slug":"invalid-v-for-expression-exp","errorCode":null,"errorMessage":"Invalid v-for expression: ${exp}","messagePattern":"Invalid v-for expression: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/weex-template-compiler/build.js","lineNumber":1647,"sourceCode":"    }\n    el.key = exp;\n  }\n}\n\nfunction processRef (el) {\n  var ref = getBindingAttr(el, 'ref');\n  if (ref) {\n    el.ref = ref;\n    el.refInFor = checkInFor(el);\n  }\n}\n\nfunction processFor (el) {\n  var exp;\n  if ((exp = getAndRemoveAttr(el, 'v-for'))) {\n    var inMatch = exp.match(forAliasRE);\n    if (!inMatch) {\n      process.env.NODE_ENV !== 'production' && warn(\n        (\"Invalid v-for expression: \" + exp)\n      );\n      return\n    }\n    el.for = inMatch[2].trim();\n    var alias = inMatch[1].trim();\n    var iteratorMatch = alias.match(forIteratorRE);\n    if (iteratorMatch) {\n      el.alias = iteratorMatch[1].trim();\n      el.iterator1 = iteratorMatch[2].trim();\n      if (iteratorMatch[3]) {\n        el.iterator2 = iteratorMatch[3].trim();\n      }\n    } else {\n      el.alias = alias;\n    }\n  }\n}","sourceCodeStart":1629,"sourceCodeEnd":1665,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-template-compiler/build.js#L1629-L1665","documentation":"The v-for attribute value could not be parsed by forAliasRE, which expects the form 'alias in expression' (also 'of'). The compiler warns with the raw expression and skips generating the list render, so the element will not loop as intended.","triggerScenarios":"Writing v-for with a missing or malformed 'in'/'of' clause, e.g. v-for=\"item\" or v-for=\"(item, index)\" with no iterable expression, so exp.match(forAliasRE) returns null in dev mode.","commonSituations":"Typos like v-for=\"item inin items\", forgetting the iterable after the alias, or dynamic v-for bindings that resolve to an invalid string.","solutions":["Include the 'in' (or 'of') alias clause: v-for=\"item in items\"","Check the expression for typos or missing parts","If v-for is dynamic, ensure the bound value always yields a valid 'alias in expr' string"],"exampleFix":"// before\n<li v-for=\"item\">{{ item }}</li>\n// after\n<li v-for=\"item in items\">{{ item }}</li>","handlingStrategy":"validation","validationCode":"function isValidVFor(exp) {\n  return typeof exp === 'string' && /\\s(?:in|of)\\s/.test(exp);\n}\n// check all v-for attributes in a template source\nfunction scanVFor(template) {\n  const re = /v-for=\"([^\"]*)\"/g; let m, bad = [];\n  while ((m = re.exec(template))) if (!isValidVFor(m[1])) bad.push(m[1]);\n  return bad;\n}","typeGuard":"function hasValidVFor(exp) {\n  return typeof exp === 'string' && /\\s(?:in|of)\\s/.test(exp);\n}","tryCatchPattern":null,"preventionTips":["Always write v-for=\"alias in iterable\"","Lint templates for v-for values lacking ' in ' or ' of '","Avoid dynamic v-for expressions that could produce malformed strings"],"tags":["v-for","template","syntax","vue","weex"],"backgroundTag":"invalid-v-for-expression","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}