{"record":{"id":"21a9b5f5c13185e9","repo":"Meituan-Dianping/mpvue","slug":"template-cannot-be-keyed-place-the-key-on-real-21a9b5","errorCode":null,"errorMessage":"<template> cannot be keyed. Place the key on real elements instead.","messagePattern":"<template> cannot be keyed\\. Place the key on real elements instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/parser/index.js","lineNumber":316,"sourceCode":"  if (l) {\n    const attrs = el.attrs = new Array(l)\n    for (let i = 0; i < l; i++) {\n      attrs[i] = {\n        name: el.attrsList[i].name,\n        value: JSON.stringify(el.attrsList[i].value)\n      }\n    }\n  } else if (!el.pre) {\n    // non root node in pre blocks with no attributes\n    el.plain = true\n  }\n}\n\nfunction processKey (el) {\n  const exp = getBindingAttr(el, 'key')\n  if (exp) {\n    if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {\n      warn(`<template> cannot be keyed. Place the key on real elements instead.`)\n    }\n    el.key = exp\n  }\n}\n\nfunction processRef (el) {\n  const ref = getBindingAttr(el, 'ref')\n  if (ref) {\n    el.ref = ref\n    el.refInFor = checkInFor(el)\n  }\n}\n\nfunction processFor (el) {\n  let exp\n  if ((exp = getAndRemoveAttr(el, 'v-for'))) {\n    const inMatch = exp.match(forAliasRE)\n    if (!inMatch) {","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/compiler/parser/index.js#L298-L334","documentation":"Dev-only warning in processKey: a key attribute was placed on a <template> element. <template> is an abstract wrapper compiled away with no real DOM node, so a key has nothing to attach to; keys belong on the real rendered elements inside it.","triggerScenarios":"Thrown at src/compiler/parser/index.js:316 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the :key from <template> onto the real element(s) inside it","If keying a group, wrap in a keyed real element or key each child individually"],"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"}