defineComputed() — vue Function Reference
Architecture documentation for the defineComputed() function in state.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 743f92db_5862_0bb2_3ad1_47ccd2ae1c10["defineComputed()"] 079339bc_f0ce_0fd0_3d1b_26a2dc073616["state.ts"] 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 -->|defined in| 079339bc_f0ce_0fd0_3d1b_26a2dc073616 3430fea3_ff5d_f4b7_a4ca_f1257a327ab1["initComputed()"] 3430fea3_ff5d_f4b7_a4ca_f1257a327ab1 -->|calls| 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 920e66ae_3cc4_9da1_e697_9e4605afb494["initComputed()"] 920e66ae_3cc4_9da1_e697_9e4605afb494 -->|calls| 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 7a9733ae_710c_5b35_fded_f5829a6aeedc["createComputedGetter()"] 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 -->|calls| 7a9733ae_710c_5b35_fded_f5829a6aeedc 343e10de_74f2_8519_999e_36d9a2e41542["createGetterInvoker()"] 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 -->|calls| 343e10de_74f2_8519_999e_36d9a2e41542 style 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/core/instance/state.ts lines 226–254
export function defineComputed(
target: any,
key: string,
userDef: Record<string, any> | (() => any)
) {
const shouldCache = !isServerRendering()
if (isFunction(userDef)) {
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
: createGetterInvoker(userDef)
sharedPropertyDefinition.set = noop
} else {
sharedPropertyDefinition.get = userDef.get
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
: createGetterInvoker(userDef.get)
: noop
sharedPropertyDefinition.set = userDef.set || noop
}
if (__DEV__ && sharedPropertyDefinition.set === noop) {
sharedPropertyDefinition.set = function () {
warn(
`Computed property "${key}" was assigned to but it has no setter.`,
this
)
}
}
Object.defineProperty(target, key, sharedPropertyDefinition)
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does defineComputed() do?
defineComputed() is a function in the vue codebase, defined in src/core/instance/state.ts.
Where is defineComputed() defined?
defineComputed() is defined in src/core/instance/state.ts at line 226.
What does defineComputed() call?
defineComputed() calls 2 function(s): createComputedGetter, createGetterInvoker.
What calls defineComputed()?
defineComputed() is called by 2 function(s): initComputed, initComputed.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free