Meituan-Dianping/mpvue · error
Inline-template components must have exactly one child eleme
Error message
Inline-template components must have exactly one child element.
What it means
Dev-only codegen warning from genInlineTemplate: a component using the inline-template attribute must have exactly one element child, because that single child's AST is compiled as the component's own template. Multiple children or a non-element (text) first child make the inline template ambiguous, so compilation cannot proceed meaningfully.
Source
Thrown at packages/weex-template-compiler/build.js:3003
// returns true if it also needs a runtime counterpart.
needRuntime = !!gen(el, dir, state.warn);
}
if (needRuntime) {
hasRuntime = true;
res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
}
}
if (hasRuntime) {
return res.slice(0, -1) + ']'
}
}
function genInlineTemplate (el, state) {
var ast = el.children[0];
if (process.env.NODE_ENV !== 'production' && (
el.children.length > 1 || ast.type !== 1
)) {
state.warn('Inline-template components must have exactly one child element.');
}
if (ast.type === 1) {
var inlineRenderFns = generate(ast, state.options);
return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
}
}
function genScopedSlots (
slots,
state
) {
return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
return genScopedSlot(key, slots[key], state)
}).join(',')) + "])")
}
function genScopedSlot (
key,View on GitHub (pinned to 6c5d78ee04)
Solutions
- Wrap the children in a single root element inside the inline-template component
- Remove inline-template and use a normal scoped slot instead (recommended)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/weex-template-compiler/build.js:3003 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/91af4858eef3d2b1.
Report an issue: GitHub.