{"record":{"id":"4152e7995ed1980f","repo":"Meituan-Dianping/mpvue","slug":"the-computed-property-key-is-already-defined-4152e7","errorCode":null,"errorMessage":"The computed property \"${key}\" is already defined as a prop.","messagePattern":"The computed property \"(.+?)\" is already defined as a prop\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/core/instance/state.js","lineNumber":197,"sourceCode":"          `No getter function has been defined for computed property \"${key}\".`,\n          vm\n        )\n        getter = noop\n      }\n    }\n    // create internal watcher for the computed property.\n    watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions)\n\n    // component-defined computed properties are already defined on the\n    // component prototype. We only need to define computed properties defined\n    // at instantiation here.\n    if (!(key in vm)) {\n      defineComputed(vm, key, userDef)\n    } else if (process.env.NODE_ENV !== 'production') {\n      if (key in vm.$data) {\n        warn(`The computed property \"${key}\" is already defined in data.`, vm)\n      } else if (vm.$options.props && key in vm.$options.props) {\n        warn(`The computed property \"${key}\" is already defined as a prop.`, vm)\n      }\n    }\n  }\n}\n\nexport function defineComputed (target: any, key: string, userDef: Object | Function) {\n  if (typeof userDef === 'function') {\n    sharedPropertyDefinition.get = createComputedGetter(key)\n    sharedPropertyDefinition.set = noop\n  } else {\n    sharedPropertyDefinition.get = userDef.get\n      ? userDef.cache !== false\n        ? createComputedGetter(key)\n        : userDef.get\n      : noop\n    sharedPropertyDefinition.set = userDef.set\n      ? userDef.set\n      : noop","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/instance/state.js#L179-L215","documentation":"Vue dev-mode warning thrown by initComputed when a computed property name is already declared in the props option. Props are set on the instance before computed is initialized, so the computed definition is skipped to avoid shadowing the prop.","triggerScenarios":"Declaring the same key in both the props option and the computed option, e.g. props:['value'] plus computed:{value(){...}}; also via mixin merge introducing a computed with a prop's name.","commonSituations":"Wrapping or transforming a prop value and lazily reusing the prop name; converting a prop to computed during refactor; component libraries whose prop names collide with consumer-side computed additions.","solutions":["Rename the computed property to a distinct name","Keep the prop and drop the computed, using the prop directly","Use a scoped slot or wrapper component if you must transform the prop under the same name","Audit mixins for computed keys that match props"],"exampleFix":"// before\nexport default {\n  props: ['fullName'],\n  computed: { fullName() { return this.first + ' ' + this.last } }\n}\n// after\nexport default {\n  props: ['first', 'last'],\n  computed: { fullName() { return this.first + ' ' + this.last } }\n}","handlingStrategy":"validation","validationCode":"function checkComputedPropsCollision(options) {\n  const propKeys = (options.props || []).concat(Object.keys(options.props || {}))\n  return Object.keys(options.computed || {}).filter(k => propKeys.includes(k))\n}","typeGuard":"function hasNoComputedPropsCollision(options) { return checkComputedPropsCollision(options).length === 0 }","tryCatchPattern":null,"preventionTips":["Name computed derivatives of props distinctly (fullName vs firstName)","Run eslint-plugin-vue no-dupe-keys in CI","Never attempt to replace a prop with a computed of the same name"],"tags":["vue","reactivity","props","computed","naming-collision"],"backgroundTag":"duplicate-property-definition","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}