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
  f7c79373_1fbf_e4fb_4790_62c19b86c8b3["initMethods()"]
  910d3a96_5984_cf85_40a3_47933bd75818["state.ts"]
  f7c79373_1fbf_e4fb_4790_62c19b86c8b3 -->|defined in| 910d3a96_5984_cf85_40a3_47933bd75818
  ceeb400a_fb7f_c638_1feb_8311db20c105["initState()"]
  ceeb400a_fb7f_c638_1feb_8311db20c105 -->|calls| f7c79373_1fbf_e4fb_4790_62c19b86c8b3
  style f7c79373_1fbf_e4fb_4790_62c19b86c8b3 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, defined in src/core/instance/state.ts.
Where is initMethods() defined?
initMethods() is defined in src/core/instance/state.ts at line 285.
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