From 724a59348fa2036d5184ce65bef211d24440ee11 Mon Sep 17 00:00:00 2001 From: Darius Tall Date: Sun, 11 Sep 2016 10:54:47 -0400 Subject: [PATCH] Add undefined check for instance methods (#3656) * add undefined check for instance methods * added a warning for undefined methods * add production ENV check --- src/core/instance/state.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/instance/state.js b/src/core/instance/state.js index b6a104f0..8a7545f9 100644 --- a/src/core/instance/state.js +++ b/src/core/instance/state.js @@ -142,7 +142,11 @@ function initMethods (vm: Component) { const methods = vm.$options.methods if (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) + } } } }