diff --git a/src/core/observer/index.js b/src/core/observer/index.js index 35469aaf16a..ab730dfe3fb 100644 --- a/src/core/observer/index.js +++ b/src/core/observer/index.js @@ -196,10 +196,15 @@ export function defineReactive ( * already exist. */ export function set (target: Array | Object, key: any, val: any): any { - if (process.env.NODE_ENV !== 'production' && - (isUndef(target) || isPrimitive(target)) - ) { - warn(`Cannot set reactive property on undefined, null, or primitive value: ${(target: any)}`) + if (process.env.NODE_ENV !== 'production') { + if (isUndef(target) || isPrimitive(target)) { + warn(`Cannot set reactive property on undefined, null, or primitive value: ${(target: any)}`) + } + if (Object.getOwnPropertyDescriptor(target, key) && + (typeof (Object.getOwnPropertyDescriptor(target, key).get) === 'undefined') && + !Array.isArray(target)) { + warn(`Cannot enable reactivity on a property that is already defined: ${(key: any)}`) + } } if (Array.isArray(target) && isValidArrayIndex(key)) { target.length = Math.max(target.length, key)