Browse Source

warn computed properties that clash with existing properties (close #4562)

dev
Evan You 8 years ago
parent
commit
2b67eeca4d
  1. 8
      src/core/instance/state.js

8
src/core/instance/state.js

@ -112,6 +112,14 @@ const computedSharedDefinition = {
function initComputed (vm: Component, computed: Object) {
for (const key in computed) {
/* istanbul ignore if */
if (process.env.NODE_ENV !== 'production' && key in vm) {
warn(
`existing instance property "${key}" will be ` +
`overwritten by a computed property with the same name.`,
vm
)
}
const userDef = computed[key]
if (typeof userDef === 'function') {
computedSharedDefinition.get = makeComputedGetter(userDef, vm)

Loading…
Cancel
Save