Skip to content

Commit

Permalink
warn computed properties that are already defined as data or props
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 3, 2017
1 parent 3c02655 commit e7e86fd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/instance/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ function initComputed (vm: Component, computed: Object) {
// at instantiation here.
if (!(key in vm)) {
defineComputed(vm, key, userDef)
} else if (process.env.NODE_ENV !== 'production') {
if (key in vm.$data) {
warn(`The computed property "${key}" is already defined in data.`, vm)
} else if (vm.$options.props && key in vm.$options.props) {
warn(`The computed property "${key}" is already defined as a prop.`, vm)
}
}
}
}
Expand Down

0 comments on commit e7e86fd

Please sign in to comment.