源码stateData 中 getData 函数的一段代码 data.call(vm, vm)
Author: teenthCreated Sep 28, 2018Updated Oct 19, 2021
export function getData (data: Function, vm: Component): any {
// #7573 disable dep collection when invoking data getters
pushTarget()
try {
return data.call(vm, vm) // 为什么还要传一个vm的参数呢
} catch (e) {
handleError(e, vm, data())
return {}
} finally {
popTarget()
}
}
Source: ustbhuangyi/vue-analysis