{"record":{"id":"e5b0629c6214e44f","repo":"Meituan-Dianping/mpvue","slug":"component-option-name-should-be-an-object","errorCode":null,"errorMessage":"component option \"${name}\" should be an object.","messagePattern":"component option \"(.+?)\" should be an object\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/instance/state.js","lineNumber":65,"sourceCode":"  vm._watchers = []\n  const opts = vm.$options\n  if (opts.props) initProps(vm, opts.props)\n  if (opts.methods) initMethods(vm, opts.methods)\n  if (opts.data) {\n    initData(vm)\n  } else {\n    observe(vm._data = {}, true /* asRootData */)\n  }\n  if (opts.computed) initComputed(vm, opts.computed)\n  if (opts.watch && opts.watch !== nativeWatch) {\n    initWatch(vm, opts.watch)\n  }\n}\n\nfunction checkOptionType (vm: Component, name: string) {\n  const option = vm.$options[name]\n  if (!isPlainObject(option)) {\n    warn(\n      `component option \"${name}\" should be an object.`,\n      vm\n    )\n  }\n}\n\nfunction initProps (vm: Component, propsOptions: Object) {\n  const propsData = vm.$options.propsData || {}\n  const props = vm._props = {}\n  // cache prop keys so that future props updates can iterate using Array\n  // instead of dynamic object key enumeration.\n  const keys = vm.$options._propKeys = []\n  const isRoot = !vm.$parent\n  // root instance props should be converted\n  observerState.shouldConvert = isRoot\n  for (const key in propsOptions) {\n    keys.push(key)\n    const value = validateProp(key, propsOptions, propsData, vm)","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/instance/state.js#L47-L83","documentation":"Produced by checkOptionType, a shared dev-only validator invoked at the top of initMethods, initComputed and initWatch before those initializers run. It checks that the corresponding option (methods, computed, or watch) is a plain object; passing an array, a function, a string or null instead triggers this warning naming the offending option. Initialization then proceeds over the malformed value and effectively yields no methods/computed/watchers from it.","triggerScenarios":"Thrown at src/core/instance/state.js:65 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the option as an object keyed by member name, e.g. methods: { onClick() {...} } or computed: { fullName() {...} }","For watch use object syntax: watch: { a: handler } (the array 'top-level watch' form watch: [fn] is not supported here)","Remove trailing commas/typos that turn the option into a non-object value"],"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"}