{"record":{"id":"3de4b929513d168e","repo":"Meituan-Dianping/mpvue","slug":"method-key-has-already-been-defined-as-a-data-3de4b9","errorCode":null,"errorMessage":"method \"${key}\" has already been defined as a data property.","messagePattern":"method \"(.+?)\" has already been defined as a data property\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/instance/state.js","lineNumber":138,"sourceCode":"    : data || {}\n  if (!isPlainObject(data)) {\n    data = {}\n    process.env.NODE_ENV !== 'production' && warn(\n      'data functions should return an object:\\n' +\n      'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',\n      vm\n    )\n  }\n  // proxy data on instance\n  const keys = Object.keys(data)\n  const props = vm.$options.props\n  const methods = vm.$options.methods\n  let i = keys.length\n  while (i--) {\n    const key = keys[i]\n    if (process.env.NODE_ENV !== 'production') {\n      if (methods && hasOwn(methods, key)) {\n        warn(\n          `method \"${key}\" has already been defined as a data property.`,\n          vm\n        )\n      }\n    }\n    if (props && hasOwn(props, key)) {\n      process.env.NODE_ENV !== 'production' && warn(\n        `The data property \"${key}\" is already declared as a prop. ` +\n        `Use prop default value instead.`,\n        vm\n      )\n    } else if (!isReserved(key)) {\n      proxy(vm, `_data`, key)\n    }\n  }\n  // observe data\n  observe(data, true /* asRootData */)\n}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/instance/state.js#L120-L156","documentation":"Fires inside the initData proxying loop when a key in data collides with a key already defined in the options.methods object. Both data properties and methods are proxied directly onto the vm instance, so a shared name means whichever is defined later would overwrite the earlier binding; Vue warns (in dev) and the data property takes the instance slot, shadowing the method. The method itself still exists in vm.$options.methods.","triggerScenarios":"Thrown at src/core/instance/state.js:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename either the data property or the method so they no longer share a key","If a value and an action belong together, keep the value in data and give the method a distinct verb-style name (e.g. value 'count', method 'incrementCount')"],"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"}