learnVue
learnVue copied to clipboard
:octocat:Vue.js 源码解析
``` function defineReactive (obj, key, val, cb) { let val = val Object.defineProperty(obj, key, { enumerable: true, configurable: true, get: ()=>{ /*....依赖收集等....*/ /*Github:https://github.com/answershuto*/ return val }, set:newVal=> { val =...
```javascript class Vue { constructor(options) { this._data = options.data; observer(this._data, options.render); let watcher = new Watcher(this, ); // 这括号里是没写完吗 } } ```
[这里如果当前浏览器支持__proto__属性,则直接覆盖当前数组对象原型上的原生数组方法,如果不支持该属性,则直接覆盖数组对象的原型。](https://github.com/answershuto/learnVue/blob/master/docs/%E4%BB%8E%E6%BA%90%E7%A0%81%E8%A7%92%E5%BA%A6%E5%86%8D%E7%9C%8B%E6%95%B0%E6%8D%AE%E7%BB%91%E5%AE%9A.MarkDown#observer) 这里写反了吧 如果支持__proto__属性,直接覆盖数组对象的原型,不支持则一一覆盖数组对象上的方法
updateChildren部分,倒数第二个图有错误,那3个新Vnode, 应该插到 oldStartIdx前面,不是放到后面
````javascript Vue.prototype.$emit = function (event: string): Component { const vm: Component = this if (process.env.NODE_ENV !== 'production') { const lowerCaseEvent = event.toLowerCase() if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { tip(...

比如const qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')' const ncname = '[a‐zA‐Z_][\\w\\‐\\.]*'; 这样的正则为什么就可以匹配到标签了呢 那一整章节后面都不大理解,痛苦