{"record":{"id":"9b949f674e03e662","repo":"Meituan-Dianping/mpvue","slug":"method-key-has-an-undefined-value-in-the-comp","errorCode":null,"errorMessage":"method \"${key}\" has an undefined value in the component definition. Did you reference the function correctly?","messagePattern":"method \"(.+?)\" has an undefined value in the component definition\\. Did you reference the function correctly\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/weex-vue-framework/factory.js","lineNumber":3252,"sourceCode":"      if (watcher.dirty) {\n        watcher.evaluate();\n      }\n      if (Dep.target) {\n        watcher.depend();\n      }\n      return watcher.value\n    }\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) {","sourceCodeStart":3234,"sourceCodeEnd":3270,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-vue-framework/factory.js#L3234-L3270","documentation":"Vue binds each entry of the methods option onto the instance. If a method's value is null or undefined, Vue silently substitutes noop so calls don't crash, but warns that the reference was probably a mistake (e.g. a misnamed import).","triggerScenarios":"methods: { handler: someFn } where someFn is undefined — bad import name, circular import not yet initialized, or methods: { handler: undefined } explicitly.","commonSituations":"Renaming an imported function without updating methods, tree-shaking or circular-dependency issues yielding undefined at definition time, typos in utility module names, or referencing a function before it is declared in the module.","solutions":["Fix the import/reference so the method points to a real function","Log or console-check the value at module scope to find the undefined source","Remove the methods entry if it is no longer used","For circular imports, defer binding (e.g. methods: { handler() { return importedFn(); } })"],"exampleFix":"// before\nimport { submitFoem } from './api'; // typo\nmethods: { onSubmit: submitFoem }\n// after\nimport { submitForm } from './api';\nmethods: { onSubmit: submitForm }","handlingStrategy":"type-guard","validationCode":"function validateMethods(options) {\n  Object.entries(options.methods || {}).forEach(([k, fn]) => {\n    if (fn == null) throw new TypeError(`method \"${k}\" is undefined in component definition`);\n  });\n}","typeGuard":"function isDefinedFn(v) {\n  return typeof v === 'function';\n}","tryCatchPattern":null,"preventionTips":["Verify imported function names before binding them to methods","Watch for circular imports yielding undefined at module init","Use default exports carefully when destructuring imports"],"tags":["vue","methods","undefined","imports"],"backgroundTag":"undefined-method-reference","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}