Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/instance/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add else if (process.env.NODE_ENV !== 'production') here so that the warning can be stripped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why do you provide vm as a second variable? it will log vm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used to get the component name, if available:

https://github.com/vuejs/vue/blob/dev/src/core/util/debug.js#L10-L13

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I get it, You saved me!!!!!!!!!!

}
}
}
}
Expand Down