{"record":{"id":"fed86e16843ddc9c","repo":"Meituan-Dianping/mpvue","slug":"v-once-can-only-be-used-inside-v-for-that-is-keyed","errorCode":null,"errorMessage":"v-once can only be used inside v-for that is keyed. ","messagePattern":"v-once can only be used inside v-for that is keyed\\. ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/weex-template-compiler/build.js","lineNumber":2816,"sourceCode":"}\n\n// v-once\nfunction genOnce (el, state) {\n  el.onceProcessed = true;\n  if (el.if && !el.ifProcessed) {\n    return genIf(el, state)\n  } else if (el.staticInFor) {\n    var key = '';\n    var parent = el.parent;\n    while (parent) {\n      if (parent.for) {\n        key = parent.key;\n        break\n      }\n      parent = parent.parent;\n    }\n    if (!key) {\n      process.env.NODE_ENV !== 'production' && state.warn(\n        \"v-once can only be used inside v-for that is keyed. \"\n      );\n      return genElement(el, state)\n    }\n    return (\"_o(\" + (genElement(el, state)) + \",\" + (state.onceId++) + (key ? (\",\" + key) : \"\") + \")\")\n  } else {\n    return genStatic(el, state)\n  }\n}\n\nfunction genIf (\n  el,\n  state,\n  altGen,\n  altEmpty\n) {\n  el.ifProcessed = true; // avoid recursion\n  return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)","sourceCodeStart":2798,"sourceCodeEnd":2834,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-template-compiler/build.js#L2798-L2834","documentation":"Dev-only codegen warning from genOnce: an element marked v-once sits inside a v-for whose ancestor chain has no key. Static-once nodes inside a keyed diff require the enclosing v-for key to track identity; without it the _o() cache marker cannot be generated correctly, so the compiler warns and falls back to normal element generation.","triggerScenarios":"Thrown at packages/weex-template-compiler/build.js:2816 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a unique :key to the v-for that contains the v-once element","Remove v-once if the node must update per render"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}