Created
May 13, 2019 03:16
-
-
Save tdondich/80a3e0fc83cd1347049c12fabe519746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initMethods (vm: Component, methods: Object) { | |
const props = vm.$options.props | |
for (const key in methods) { | |
if (process.env.NODE_ENV !== 'production') { | |
if (typeof methods[key] !== 'function') { | |
warn( | |
`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` + | |
`Did you reference the function correctly?`, | |
vm | |
) | |
} | |
if (props && hasOwn(props, key)) { | |
warn( | |
`Method "${key}" has already been defined as a prop.`, | |
vm | |
) | |
} | |
if ((key in vm) && isReserved(key)) { | |
warn( | |
`Method "${key}" conflicts with an existing Vue instance method. ` + | |
`Avoid defining component methods that start with _ or $.` | |
) | |
} | |
} | |
vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment