Browse Source

Add undefined check for instance methods (#3656)

* add undefined check for instance methods

* added a warning for undefined methods

* add production ENV check
dev
Darius Tall 8 years ago
committed by Evan You
parent
commit
724a59348f
  1. 6
      src/core/instance/state.js

6
src/core/instance/state.js

@ -142,7 +142,11 @@ function initMethods (vm: Component) {
const methods = vm.$options.methods const methods = vm.$options.methods
if (methods) { if (methods) {
for (const key in methods) { for (const key in methods) {
vm[key] = bind(methods[key], vm) if (methods[key] != null) {
vm[key] = bind(methods[key], vm)
} else if (process.env.NODE_ENV !== 'production') {
warn(`The method ${key} on vue instance is undefined.`, vm)
}
} }
} }
} }

Loading…
Cancel
Save