Meituan-Dianping/mpvue · error
component option "${name}" should be an object.
Error message
component option "${name}" should be an object. What it means
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.
Source
Thrown at src/core/instance/state.js:65
vm._watchers = []
const opts = vm.$options
if (opts.props) initProps(vm, opts.props)
if (opts.methods) initMethods(vm, opts.methods)
if (opts.data) {
initData(vm)
} else {
observe(vm._data = {}, true /* asRootData */)
}
if (opts.computed) initComputed(vm, opts.computed)
if (opts.watch && opts.watch !== nativeWatch) {
initWatch(vm, opts.watch)
}
}
function checkOptionType (vm: Component, name: string) {
const option = vm.$options[name]
if (!isPlainObject(option)) {
warn(
`component option "${name}" should be an object.`,
vm
)
}
}
function initProps (vm: Component, propsOptions: Object) {
const propsData = vm.$options.propsData || {}
const props = vm._props = {}
// cache prop keys so that future props updates can iterate using Array
// instead of dynamic object key enumeration.
const keys = vm.$options._propKeys = []
const isRoot = !vm.$parent
// root instance props should be converted
observerState.shouldConvert = isRoot
for (const key in propsOptions) {
keys.push(key)
const value = validateProp(key, propsOptions, propsData, vm)View on GitHub (pinned to 6c5d78ee04)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/core/instance/state.js:65 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02).
Data as JSON: /api/errors/e5b0629c6214e44f.
Report an issue: GitHub.