MCPcopy
hub / github.com/fanmingming/live / initData

Function initData

m3u8/vue.js:4692–4732  ·  view source on GitHub ↗
(vm)

Source from the content-addressed store, hash-verified

4690 }
4691
4692 function initData (vm) {
4693 var data = vm.$options.data;
4694 data = vm._data = typeof data === 'function'
4695 ? getData(data, vm)
4696 : data || {};
4697 if (!isPlainObject(data)) {
4698 data = {};
4699 warn(
4700 'data functions should return an object:\n' +
4701 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
4702 vm
4703 );
4704 }
4705 // proxy data on instance
4706 var keys = Object.keys(data);
4707 var props = vm.$options.props;
4708 var methods = vm.$options.methods;
4709 var i = keys.length;
4710 while (i--) {
4711 var key = keys[i];
4712 {
4713 if (methods && hasOwn(methods, key)) {
4714 warn(
4715 ("Method \"" + key + "\" has already been defined as a data property."),
4716 vm
4717 );
4718 }
4719 }
4720 if (props && hasOwn(props, key)) {
4721 warn(
4722 "The data property \"" + key + "\" is already declared as a prop. " +
4723 "Use prop default value instead.",
4724 vm
4725 );
4726 } else if (!isReserved(key)) {
4727 proxy(vm, "_data", key);
4728 }
4729 }
4730 // observe data
4731 observe(data, true /* asRootData */);
4732 }
4733
4734 function getData (data, vm) {
4735 // #7573 disable dep collection when invoking data getters

Callers 1

initStateFunction · 0.85

Calls 7

getDataFunction · 0.85
isPlainObjectFunction · 0.85
warnFunction · 0.85
hasOwnFunction · 0.85
isReservedFunction · 0.85
proxyFunction · 0.85
observeFunction · 0.85

Tested by

no test coverage detected