initData() — vue Function Reference
Architecture documentation for the initData() function in state.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD a06d5e75_873a_9e84_3260_353c9ffb6493["initData()"] 7d6ab8ef_bd4c_49b2_1b21_a805de50af72["initState()"] 7d6ab8ef_bd4c_49b2_1b21_a805de50af72 -->|calls| a06d5e75_873a_9e84_3260_353c9ffb6493 4a217f96_6206_e5df_d58a_163a7fa28307["getData()"] a06d5e75_873a_9e84_3260_353c9ffb6493 -->|calls| 4a217f96_6206_e5df_d58a_163a7fa28307 116cddf0_8d78_82e1_fbc7_5754697f785e["proxy()"] a06d5e75_873a_9e84_3260_353c9ffb6493 -->|calls| 116cddf0_8d78_82e1_fbc7_5754697f785e 38718d0e_50b6_f32c_7ce6_c7fe083f1ba2["observe()"] a06d5e75_873a_9e84_3260_353c9ffb6493 -->|calls| 38718d0e_50b6_f32c_7ce6_c7fe083f1ba2 style a06d5e75_873a_9e84_3260_353c9ffb6493 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/core/instance/state.ts lines 128–166
function initData(vm: Component) {
let data: any = vm.$options.data
data = vm._data = isFunction(data) ? getData(data, vm) : data || {}
if (!isPlainObject(data)) {
data = {}
__DEV__ &&
warn(
'data functions should return an object:\n' +
'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
vm
)
}
// proxy data on instance
const keys = Object.keys(data)
const props = vm.$options.props
const methods = vm.$options.methods
let i = keys.length
while (i--) {
const key = keys[i]
if (__DEV__) {
if (methods && hasOwn(methods, key)) {
warn(`Method "${key}" has already been defined as a data property.`, vm)
}
}
if (props && hasOwn(props, key)) {
__DEV__ &&
warn(
`The data property "${key}" is already declared as a prop. ` +
`Use prop default value instead.`,
vm
)
} else if (!isReserved(key)) {
proxy(vm, `_data`, key)
}
}
// observe data
const ob = observe(data)
ob && ob.vmCount++
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does initData() do?
initData() is a function in the vue codebase.
What does initData() call?
initData() calls 3 function(s): getData, observe, proxy.
What calls initData()?
initData() 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