1. function initMethods (vm: Component, methods: Object) {
    2. const props = vm.$options.props
    3. for (const key in methods) {
    4. if (process.env.NODE_ENV !== 'production') {
    5. if (typeof methods[key] !== 'function') {
    6. warn(
    7. `Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
    8. `Did you reference the function correctly?`,
    9. vm
    10. )
    11. }
    12. if (props && hasOwn(props, key)) {
    13. warn(
    14. `Method "${key}" has already been defined as a prop.`,
    15. vm
    16. )
    17. }
    18. if ((key in vm) && isReserved(key)) {
    19. warn(
    20. `Method "${key}" conflicts with an existing Vue instance method. ` +
    21. `Avoid defining component methods that start with _ or $.`
    22. )
    23. }
    24. }
    25. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm)
    26. }
    27. }