{"record":{"id":"e35b19feb4e313e4","repo":"Meituan-Dianping/mpvue","slug":"method-key-has-already-been-defined-as-a-prop","errorCode":null,"errorMessage":"method \"${key}\" has already been defined as a prop.","messagePattern":"method \"(.+?)\" has already been defined as a prop\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/weex-vue-framework/factory.js","lineNumber":3259,"sourceCode":"    }\n  }\n}\n\nfunction initMethods (vm, methods) {\n  process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'methods');\n  var props = vm.$options.props;\n  for (var key in methods) {\n    vm[key] = methods[key] == null ? noop : bind(methods[key], vm);\n    if (process.env.NODE_ENV !== 'production') {\n      if (methods[key] == null) {\n        warn(\n          \"method \\\"\" + key + \"\\\" has an undefined value in the component definition. \" +\n          \"Did you reference the function correctly?\",\n          vm\n        );\n      }\n      if (props && hasOwn(props, key)) {\n        warn(\n          (\"method \\\"\" + key + \"\\\" has already been defined as a prop.\"),\n          vm\n        );\n      }\n    }\n  }\n}\n\nfunction initWatch (vm, watch) {\n  process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'watch');\n  for (var key in watch) {\n    var handler = watch[key];\n    if (Array.isArray(handler)) {\n      for (var i = 0; i < handler.length; i++) {\n        createWatcher(vm, key, handler[i]);\n      }\n    } else {\n      createWatcher(vm, key, handler);","sourceCodeStart":3241,"sourceCodeEnd":3277,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-vue-framework/factory.js#L3241-L3277","documentation":"During methods initialization, Vue checks each method key against the component's props; a method sharing a prop's name would overwrite the prop binding on the instance (or be overwritten), so Vue warns about the conflict.","triggerScenarios":"Declaring a method whose name equals a declared prop, e.g. props: ['open'] and methods: { open() {...} }.","commonSituations":"Mixin methods colliding with component props, generic method names like 'value', 'title', 'open' matching prop names, or legacy components gaining a prop during an API change.","solutions":["Rename the method (e.g. openModal, doOpen)","Rename the prop if it is your own component API and the name is better suited to a function","Remove the method if it duplicates behavior already provided by the prop usage pattern"],"exampleFix":"// before\nprops: ['open'],\nmethods: { open() { this.visible = true; } }\n// after\nprops: ['open'],\nmethods: { openPanel() { this.visible = true; } }","handlingStrategy":"validation","validationCode":"function checkMethodPropCollisions(options) {\n  const props = options.props || [];\n  const propNames = Array.isArray(props) ? props : Object.keys(props);\n  return Object.keys(options.methods || {}).filter(k => propNames.includes(k));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use verb-prefixed method names (openX, setX) to avoid prop collisions","Audit mixins whose methods may match host props","Keep component APIs reviewed when adding props"],"tags":["vue","methods","props","naming-collision"],"backgroundTag":"option-name-collision","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}