Skip to content

Commit d77fce1

Browse files
authored
Add files via upload
1 parent 23820d8 commit d77fce1

25 files changed

+1570
-0
lines changed

Vue源码分析.svg

Lines changed: 832 additions & 0 deletions
Loading

vue.js中HOOK函数.docx

14.8 KB
Binary file not shown.
Binary file not shown.

vue数据监听.docx

40.1 KB
Binary file not shown.

vue源码分析.docx

13 KB
Binary file not shown.

vue源码分析.jpg

42.6 KB
Loading

vue源码帖子分析.docx

11.5 KB
Binary file not shown.

vue零散代码分析.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<body>
3+
<script type="text/javascript">
4+
/* istanbul ignore next */
5+
function isNative (Ctor) {
6+
7+
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
8+
}
9+
function code(){
10+
var native='native codedsfgf'
11+
}
12+
console.log(typeof code === 'function')
13+
console.log( code.toString() )
14+
console.log(isNative(code))
15+
</script>
16+
</body>
17+
</html>

window_performance.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
<link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.css" />
7+
</head>
8+
<body>
9+
<script>
10+
for(var i=0; i<1000000000; i++){
11+
12+
}
13+
;
14+
(function() {
15+
16+
handleAddListener('load', getTiming)
17+
18+
function handleAddListener(type, fn) {
19+
if(window.addEventListener) {
20+
window.addEventListener(type, fn)
21+
} else {
22+
window.attachEvent('on' + type, fn)
23+
}
24+
}
25+
26+
function getTiming() {
27+
try {
28+
var time = performance.timing;
29+
var timingObj = {};
30+
31+
var loadTime = (time.loadEventEnd - time.loadEventStart) / 1000;
32+
33+
if(loadTime < 0) {
34+
setTimeout(function() {
35+
getTiming();
36+
}, 200);
37+
return;
38+
}
39+
40+
timingObj['重定向时间'] = (time.redirectEnd - time.redirectStart) / 1000;
41+
timingObj['DNS解析时间'] = (time.domainLookupEnd - time.domainLookupStart) / 1000;
42+
timingObj['TCP完成握手时间'] = (time.connectEnd - time.connectStart) / 1000;
43+
timingObj['HTTP请求响应完成时间'] = (time.responseEnd - time.requestStart) / 1000;
44+
timingObj['DOM开始加载前所花费时间'] = (time.responseEnd - time.navigationStart) / 1000;
45+
timingObj['DOM加载完成时间'] = (time.domComplete - time.domLoading) / 1000;
46+
timingObj['DOM结构解析完成时间'] = (time.domInteractive - time.domLoading) / 1000;
47+
timingObj['脚本加载时间'] = (time.domContentLoadedEventEnd - time.domContentLoadedEventStart) / 1000;
48+
timingObj['onload事件时间'] = (time.loadEventEnd - time.loadEventStart) / 1000;
49+
timingObj['页面完全加载时间'] = (timingObj['重定向时间'] + timingObj['DNS解析时间'] + timingObj['TCP完成握手时间'] + timingObj['HTTP请求响应完成时间'] + timingObj['DOM结构解析完成时间'] + timingObj['DOM加载完成时间']);
50+
51+
for(item in timingObj) {
52+
console.log(item + ":" + timingObj[item] + '毫秒(ms)');
53+
}
54+
55+
console.log(performance.timing);
56+
57+
} catch(e) {
58+
console.log(timingObj)
59+
console.log(performance.timing);
60+
}
61+
}
62+
})();
63+
</script>
64+
</body>
65+
</html>

window_performance1.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
<link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.css" />
7+
</head>
8+
<body>
9+
<script>
10+
// https://segmentfault.com/a/1190000002445735
11+
12+
// window.webkitPerformance : chrome6-9
13+
// window.performance : ie9 chrome10+
14+
{
15+
16+
var perf = window.performance||window.webkitPerformance;
17+
18+
19+
/* istanbul ignore if */
20+
if (
21+
perf &&
22+
perf.mark &&
23+
perf.measure &&
24+
perf.clearMarks &&
25+
perf.clearMeasures
26+
) {
27+
mark = function (tag) { return perf.mark(tag); };
28+
measure = function (name, startTag, endTag) {
29+
perf.measure(name, startTag, endTag);
30+
perf.clearMarks(startTag);
31+
perf.clearMarks(endTag);
32+
perf.clearMeasures(name);
33+
};
34+
}
35+
}
36+
console.log(perf.mark)
37+
38+
console.log(mark('vue-perf-start1'))
39+
console.log(measure)
40+
41+
</script>
42+
</body>
43+
</html>

with.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
7+
</head>
8+
<body>
9+
<script>
10+
//https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/with
11+
// 不建议使用with语句,因为它可能是混淆错误和兼容性问题的根源。有关详细信息,请参阅下面“说明”一节中的“歧义对比”部分。
12+
// with语句 扩展一个语句的作用域链。
13+
// 语法节
14+
// with (expression) {
15+
// statement
16+
// }
17+
// expression
18+
// 将给定的表达式添加到在评估语句时使用的作用域链上。表达式周围的括号是必需的。
19+
// statement
20+
// 任何语句。要执行多个语句,请使用一个块语句 ({ ... })对这些语句进行分组。
21+
//性能方面的利与弊节
22+
//利:with语句可以在不造成性能损失的情況下,减少变量的长度。其造成的附加计算量很少。使用'with'可以减少不必要的指针路径解析运算。需要注意的是,很多情況下,也可以不使用with语句,而是使用一个临时变量来保存指针,来达到同样的效果。
23+
//
24+
//弊:with语句使得程序在查找变量值时,都是先在指定的对象中查找。所以那些本来不是这个对象的属性的变量,查找起来将会很慢。如果是在对性能要求较高的场合,'with'下面的statement语句中的变量,只应该包含这个指定对象的属性。
25+
//
26+
//语义不明的弊端节
27+
//弊端:with语句使得代码不易阅读,同时使得JavaScript编译器难以在作用域链上查找某个变量,难以决定应该在哪个对象上来取值。请看下面的例子:
28+
var a={};
29+
a.name='张三';a.sex='女';
30+
console.log(a.name);
31+
console.log(a.sex);
32+
with(a){
33+
console.log(name);
34+
console.log(sex);
35+
}
36+
</script>
37+
</body>
38+
</html>

wrapFilter.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<script>
9+
function wrapFilter(exp, filter) {
10+
var i = filter.indexOf('('); //返回字符串第一次出现索引的位置
11+
console.log('i='+i)
12+
if (i < 0) {
13+
// _f: resolveFilter
14+
return ("_f(\"" + filter + "\")(" + exp + ")") //闭包
15+
} else {
16+
//name 是 从字符串开始到(结束的字符串,不包含(
17+
var name = filter.slice(0, i); //截取字符串 arrayObject.slice(start,end)
18+
console.log('==name==')
19+
console.log(name)
20+
21+
//args是从(开始匹配,到字符串末端,不包含(
22+
var args = filter.slice(i + 1); //如果 end 未被规定,那么 slice() 方法会选取从 start 到数组结尾的所有元素。
23+
console.log('==args==')
24+
console.log(args)
25+
return (
26+
"_f(\"" + name + "\")(" + exp +
27+
(
28+
args !== ')' ?
29+
',' + args
30+
: args
31+
)
32+
)
33+
}
34+
}
35+
console.log(wrapFilter('abc','defg(hijk)'))
36+
</script>
37+
</body>
38+
</html>

三木分析.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<style>
9+
div{
10+
position: absolute;
11+
position: relative;
12+
position: fixed;
13+
}
14+
</style>
15+
<script>
16+
var a=typeof function () {}==='function'&&5>4?6:9;
17+
console.log(a)
18+
console.log(typeof function () {}==='function')
19+
console.log(typeof function () {}==='asdf')
20+
console.log(true&&5>4?6:!9)
21+
console.log( false&&!false||5<4?6:9)
22+
23+
</script>
24+
</body>
25+
</html>

三木分析1.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<script>
9+
var vm= {
10+
cid:2345234,
11+
_isVue:true,
12+
$options:{
13+
_$options:'_$options'
14+
},
15+
options:{
16+
name:'vue'
17+
18+
}
19+
};
20+
var options =
21+
(typeof vm === 'function' && vm.cid != null) ?
22+
vm.options :
23+
(vm._isVue ?
24+
vm.$options || vm.constructor.options
25+
: vm || {});
26+
console.dir(options)
27+
</script>
28+
</body>
29+
</html>

与或非优先图jpg.jpg

33 KB
Loading

匿名函数执行.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<script>
9+
function noop (a, b, c) {}
10+
console.log((noop))
11+
</script>
12+
</body>
13+
</html>

发布-订阅模式.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<script>
9+
10+
var pubsub = {};
11+
12+
(function(myObject) {
13+
14+
// Storage for topics that can be broadcast 可以广播的主题的存储
15+
// or listened to 或者听
16+
var topics = {};
17+
18+
// A topic identifier 主题标识符
19+
var subUid = -1;
20+
21+
// Publish or broadcast events of interest 发布或广播感兴趣的事件
22+
// with a specific topic name and arguments 具有特定的主题名称和参数
23+
// such as the data to pass along 如数据传递
24+
myObject.publish = function( topic, args ) {
25+
26+
if ( !topics[topic] ) {
27+
return false;
28+
}
29+
30+
var subscribers = topics[topic],
31+
len = subscribers ? subscribers.length : 0;
32+
33+
while (len--) {
34+
subscribers[len].func( topic, args );
35+
}
36+
37+
return this;
38+
};
39+
40+
// Subscribe to events of interest 订阅感兴趣的事件
41+
// with a specific topic name and a 具有特定的主题名称和
42+
// callback function, to be executed 回调函数,将被执行
43+
// when the topic/event is observed 当观察到主题/事件时
44+
myObject.subscribe = function( topic, func ) {
45+
46+
if (!topics[topic]) {
47+
topics[topic] = [];
48+
}
49+
50+
var token = ( ++subUid ).toString();
51+
topics[topic].push({
52+
token: token,
53+
func: func
54+
});
55+
return token;
56+
};
57+
58+
// Unsubscribe from a specific 取消订阅
59+
// topic, based on a tokenized reference 主题,基于标记化参考
60+
// to the subscription 订阅
61+
myObject.unsubscribe = function( token ) {
62+
for ( var m in topics ) {
63+
if ( topics[m] ) {
64+
for ( var i = 0, j = topics[m].length; i < j; i++ ) {
65+
if ( topics[m][i].token === token ) {
66+
topics[m].splice( i, 1 );
67+
return token;
68+
}
69+
}
70+
}
71+
}
72+
return this;
73+
};
74+
}( pubsub ));
75+
76+
// A simple message logger that logs any topics and data received through our 一个简单的消息记录器,记录通过我们接收的任何主题和数据。
77+
// subscriber 用户
78+
var messageLogger = function ( topics, data ) {
79+
console.log( "Logging: " + topics + ": " + data );
80+
};
81+
82+
83+
// Subscribers listen for topics they have subscribed to and 订阅者监听他们订阅的主题和
84+
// invoke a callback function (e.g messageLogger) once a new 调用一个新的回调函数(例如MasigelgGER)
85+
// notification is broadcast on that topic 这个主题广播通知
86+
var subscription = pubsub.subscribe( "inbox/newMessage", messageLogger );
87+
88+
// Publishers are in charge of publishing topics or notifications of 出版商负责出版主题或通知。
89+
// interest to the application. e.g: 对应用程序有兴趣。例如:
90+
91+
pubsub.publish( "inbox/newMessage", "hello world!" );
92+
93+
// or
94+
pubsub.publish( "inbox/newMessage", ["test", "a", "b", "c"] );
95+
96+
// or
97+
pubsub.publish( "inbox/newMessage", {
98+
sender: "hello@google.com",
99+
body: "Hey again!"
100+
});
101+
102+
// We can also unsubscribe if we no longer wish for our subscribers 如果我们不再希望我们的订户,我们也可以退订。
103+
// to be notified 被通知
104+
pubsub.unsubscribe( subscription );
105+
106+
// Once unsubscribed, this for example won't result in our 一旦退订,这将不会导致我们的
107+
// messageLogger being executed as the subscriber is MasaGelgGER作为订阅服务器执行
108+
// no longer listening 不再听
109+
pubsub.publish( "inbox/newMessage", "Hello! are you still there?" );
110+
</script>
111+
</body>
112+
</html>

0 commit comments

Comments
 (0)