diff --git "a/1.2.Vue\345\210\235\345\247\213\345\214\226\350\277\207\347\250\213\345\210\206\346\236\220-new Vue()\345\210\260\345\272\225\345\201\232\344\272\206\344\273\200\344\271\210.md" "b/1.2.Vue\345\210\235\345\247\213\345\214\226\350\277\207\347\250\213\345\210\206\346\236\220-new Vue()\345\210\260\345\272\225\345\201\232\344\272\206\344\273\200\344\271\210.md" index 4bd6af7..9929790 100644 --- "a/1.2.Vue\345\210\235\345\247\213\345\214\226\350\277\207\347\250\213\345\210\206\346\236\220-new Vue()\345\210\260\345\272\225\345\201\232\344\272\206\344\273\200\344\271\210.md" +++ "b/1.2.Vue\345\210\235\345\247\213\345\214\226\350\277\207\347\250\213\345\210\206\346\236\220-new Vue()\345\210\260\345\272\225\345\201\232\344\272\206\344\273\200\344\271\210.md" @@ -1,161 +1,8 @@ -## Flow -```vuejs -// 摘自源码中src/core/config.js -export type Config = { - // user - optionMergeStrategies: { [key: string]: Function }; - silent: boolean; - productionTip: boolean; - performance: boolean; - devtools: boolean; - errorHandler: ?(err: Error, vm: Component, info: string) => void; - warnHandler: ?(msg: string, vm: Component, trace: string) => void; - ignoredElements: Array; - keyCodes: { [key: string]: number | Array }; +## 相关 +* [https://blog.csdn.net/a419419/article/details/90764860](https://blog.csdn.net/a419419/article/details/90764860) - // platform - isReservedTag: (x?: string) => boolean; - isReservedAttr: (x?: string) => boolean; - parsePlatformTagName: (x: string) => string; - isUnknownElement: (x?: string) => boolean; - getTagNamespace: (x?: string) => string | void; - mustUseProp: (tag: string, type: ?string, name: string) => boolean; +* [https://www.jianshu.com/p/4aa74c1fe182](https://www.jianshu.com/p/4aa74c1fe182) - // private - async: boolean; +* [https://segmentfault.com/a/1190000015371266](https://segmentfault.com/a/1190000015371266) - // legacy - _lifecycleHooks: Array; -}; -``` - -## DefineProperty -```vuejs -// 摘自源码中src/core/instance/state.js -Object.defineProperty(Vue.prototype, '$data', dataDef) -Object.defineProperty(Vue.prototype, '$props', propsDef) - -// 摘自源码中src/core/observer/index.js -Object.defineProperty(obj, key, { - enumerable: true, - configurable: true, - get: function reactiveGetter () { - const value = getter ? getter.call(obj) : val - if (Dep.target) { - dep.depend() - if (childOb) { - childOb.dep.depend() - if (Array.isArray(value)) { - dependArray(value) - } - } - } - return value - }, - set: function reactiveSetter (newVal) { - const value = getter ? getter.call(obj) : val - /* eslint-disable no-self-compare */ - if (newVal === value || (newVal !== newVal && value !== value)) { - return - } - /* eslint-enable no-self-compare */ - if (process.env.NODE_ENV !== 'production' && customSetter) { - customSetter() - } - // #7981: for accessor properties without setter - if (getter && !setter) return - if (setter) { - setter.call(obj, newVal) - } else { - val = newVal - } - childOb = !shallow && observe(newVal) - dep.notify() - } -}) -``` - -## Vnode - -```vuejs -// 摘自源码中src/core/vdom/vnode.js -export default class VNode { - tag: string | void; - data: VNodeData | void; - children: ?Array; - text: string | void; - elm: Node | void; - ns: string | void; - context: Component | void; // rendered in this component's scope - key: string | number | void; - componentOptions: VNodeComponentOptions | void; - componentInstance: Component | void; // component instance - parent: VNode | void; // component placeholder node - // 省略 -} -``` - -## 继承 - -```vuejs -// 摘自源码中src/core/global-api/extend.js -Vue.extend = function (extendOptions: Object): Function { - extendOptions = extendOptions || {} - const Super = this - const SuperId = Super.cid - // 省略 - Sub.prototype = Object.create(Super.prototype) - Sub.prototype.constructor = Sub - Sub.cid = cid++ - Sub.options = mergeOptions( - Super.options, - extendOptions - ) - Sub['super'] = Super - // 省略 -} -``` - -## 递归 -```vuejs -// 摘自源码中src/core/vdom/create-element.js -function applyNS (vnode, ns, force) { - vnode.ns = ns - if (vnode.tag === 'foreignObject') { - // use default namespace inside foreignObject - ns = undefined - force = true - } - if (isDef(vnode.children)) { - for (let i = 0, l = vnode.children.length; i < l; i++) { - const child = vnode.children[i] - if (isDef(child.tag) && ( - isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) { - applyNS(child, ns, force) - } - } - } -} -``` - -## Proxy -```vuejs -// 摘自源码中src/core/instance/proxy.js -initProxy = function initProxy (vm) { - if (hasProxy) { - // determine which proxy handler to use - const options = vm.$options - const handlers = options.render && options.render._withStripped - ? getHandler - : hasHandler - vm._renderProxy = new Proxy(vm, handlers) - } else { - vm._renderProxy = vm - } -} -``` - -## 相关资料 -* [https://juejin.im/post/5b4ad441f265da0f7d4eeb7a](https://juejin.im/post/5b4ad441f265da0f7d4eeb7a) -* [https://www.jianshu.com/p/c914ccd498e7](https://www.jianshu.com/p/c914ccd498e7) -* [https://blog.csdn.net/qq_24122593/article/details/53197288](https://blog.csdn.net/qq_24122593/article/details/53197288) +* [https://www.cnblogs.com/lalalagq/p/9959560.html](https://www.cnblogs.com/lalalagq/p/9959560.html) \ No newline at end of file