{"record":{"id":"9659a4bca4da6385","repo":"Meituan-Dianping/mpvue","slug":"no-getter-function-has-been-defined-for-computed-p","errorCode":null,"errorMessage":"No getter function has been defined for computed property \"${key}\".","messagePattern":"No getter function has been defined for computed property \"(.+?)\"\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/weex-vue-framework/factory.js","lineNumber":3188,"sourceCode":"    return data.call(vm)\n  } catch (e) {\n    handleError(e, vm, \"data()\");\n    return {}\n  }\n}\n\nvar computedWatcherOptions = { lazy: true };\n\nfunction initComputed (vm, computed) {\n  process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'computed');\n  var watchers = vm._computedWatchers = Object.create(null);\n\n  for (var key in computed) {\n    var userDef = computed[key];\n    var getter = typeof userDef === 'function' ? userDef : userDef.get;\n    if (process.env.NODE_ENV !== 'production') {\n      if (getter === undefined) {\n        warn(\n          (\"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) {","sourceCodeStart":3170,"sourceCodeEnd":3206,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-vue-framework/factory.js#L3170-L3206","documentation":"Each computed property must be a function (getter) or an object with at least a get function. If computed[key] is an object without a getter, Vue warns and substitutes noop so the property evaluates to undefined instead of crashing.","triggerScenarios":"Declaring computed: { foo: { set(v) {...} } } with no get, or computed: { foo: {} } / computed: { foo: undefined } in the component definition.","commonSituations":"Copy-pasting a write-only computed with a setter and deleting the getter, typos like get() vs getter, or dynamically built options objects where the getter is conditionally omitted.","solutions":["Add a get function to the computed object","Convert the property to a plain function if only reading is needed","Remove the computed entry if it is intentionally write-only and use a method or watcher instead","Check for typo'd keys (get vs getter) in the options object"],"exampleFix":"// before\ncomputed: {\n  fullName: {\n    set(v) { this.name = v; }\n  }\n}\n// after\ncomputed: {\n  fullName: {\n    get() { return this.first + ' ' + this.last; },\n    set(v) { this.name = v; }\n  }\n}","handlingStrategy":"validation","validationCode":"function validateComputedGetters(options) {\n  return Object.entries(options.computed || {})\n    .filter(([, def]) => typeof def === 'object' && typeof def.get !== 'function' && typeof def !== 'function')\n    .map(([key]) => key);\n}","typeGuard":"function hasComputedGetter(def) {\n  return typeof def === 'function' || (def && typeof def.get === 'function');\n}","tryCatchPattern":null,"preventionTips":["Write-only computed should always include a get","Check for get/getter typos","Run components in dev mode so the warning surfaces early"],"tags":["vue","computed","missing-getter","component-options"],"backgroundTag":"missing-computed-getter","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}