Meituan-Dianping/mpvue · error
The "data" option should be a function that returns a per-in
Error message
The "data" option should be a function that returns a per-instance value in component definitions.
What it means
Raised inside the data merge strategy (strats.data) when merging options without a vm — i.e. while building a component constructor via Vue.extend or global component registration. In that context childVal is present but is not a function; because a component definition is shared across instances, a static data object would be mutated by every instance simultaneously, so Vue requires the function form that returns a fresh per-instance object. The child value is effectively ignored (parentVal is kept).
Source
Thrown at src/core/util/options.js:116
? parentVal.call(vm)
: undefined
if (instanceData) {
return mergeData(instanceData, defaultData)
} else {
return defaultData
}
}
}
}
strats.data = function (
parentVal: any,
childVal: any,
vm?: Component
): ?Function {
if (!vm) {
if (childVal && typeof childVal !== 'function') {
process.env.NODE_ENV !== 'production' && warn(
'The "data" option should be a function ' +
'that returns a per-instance value in component ' +
'definitions.',
vm
)
return parentVal
}
return mergeDataOrFn.call(this, parentVal, childVal)
}
return mergeDataOrFn(parentVal, childVal, vm)
}
/**
* Hooks and props are merged as arrays.
*/
function mergeHook (View on GitHub (pinned to 6c5d78ee04)
Solutions
- Change the component's data to a function: data() { return { ... } }
- Ensure the data option in the component definition/SFC exports a function, not a plain object literal
- Root instances (new Vue({...})) may keep the object form; the function requirement applies to reusable component definitions
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/core/util/options.js:116 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/e46c8f1258ff58f4.
Report an issue: GitHub.