Home / Function/ initMethods() — vue Function Reference

initMethods() — vue Function Reference

Architecture documentation for the initMethods() function in state.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  c4516673_9ce0_4e58_5d36_4c90d7d388b3["initMethods()"]
  7d6ab8ef_bd4c_49b2_1b21_a805de50af72["initState()"]
  7d6ab8ef_bd4c_49b2_1b21_a805de50af72 -->|calls| c4516673_9ce0_4e58_5d36_4c90d7d388b3
  style c4516673_9ce0_4e58_5d36_4c90d7d388b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/instance/state.ts lines 285–310

function initMethods(vm: Component, methods: Object) {
  const props = vm.$options.props
  for (const key in methods) {
    if (__DEV__) {
      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)
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does initMethods() do?
initMethods() is a function in the vue codebase.
What calls initMethods()?
initMethods() is called by 1 function(s): initState.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free