vue-源码
本片文章只用于引导自己如何对源码进行探索,因为看到源码的时候是一脸懵逼,完全不知道该从那个地方看起,所以用本篇文章记录一下自己的解读顺序,以免自己忘记
LIFECYCLE_HOOKS
vue 钩子函数
beforeCreate
created
beforeMounte
mounted
beforeUpdate
updated
beforeDestory
destoryed
activated
deactivated
errorCaptured
serverPrefetch
SOME USERFUL METHODS
- 判断浏览器类型
1
2
3
4
5
6
7
8
9
10
11
12
13
14// packages/vue-template-compiler/browser.js
var inBrowser = typeof window !== 'undefined';
var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
var UA = inBrowser && window.navigator.userAgent.toLowerCase();
var isIE = UA && /msie|trident/.test(UA);
var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
var isEdge = UA && UA.indexOf('edge/') > 0;
var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
// Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1
var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
var isPhantomJS = UA && /phantomjs/.test(UA);
var isFF = UA && UA.match(/firefox\/(\d+)/);
makeMap
创建一个闭包判断函数,判断元素是否存在
1 | // packages/vue-template-compiler/build.js |
remove
1 | // packages/vue-template-compiler/build.js |
set
1 | function set (target, key, val) { |
https://lxx1997.github.io/2020/12/15/vue/vue-%E6%BA%90%E7%A0%81%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment
DisqusValine