{"record":{"id":"e46c8f1258ff58f4","repo":"Meituan-Dianping/mpvue","slug":"the-data-option-should-be-a-function-that-return","errorCode":null,"errorMessage":"The \"data\" option should be a function that returns a per-instance value in component definitions.","messagePattern":"The \"data\" option should be a function that returns a per-instance value in component definitions\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/util/options.js","lineNumber":116,"sourceCode":"        ? parentVal.call(vm)\n        : undefined\n      if (instanceData) {\n        return mergeData(instanceData, defaultData)\n      } else {\n        return defaultData\n      }\n    }\n  }\n}\n\nstrats.data = function (\n  parentVal: any,\n  childVal: any,\n  vm?: Component\n): ?Function {\n  if (!vm) {\n    if (childVal && typeof childVal !== 'function') {\n      process.env.NODE_ENV !== 'production' && warn(\n        'The \"data\" option should be a function ' +\n        'that returns a per-instance value in component ' +\n        'definitions.',\n        vm\n      )\n\n      return parentVal\n    }\n    return mergeDataOrFn.call(this, parentVal, childVal)\n  }\n\n  return mergeDataOrFn(parentVal, childVal, vm)\n}\n\n/**\n * Hooks and props are merged as arrays.\n */\nfunction mergeHook (","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/util/options.js#L98-L134","documentation":"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).","triggerScenarios":"Thrown at src/core/util/options.js:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}