-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
2830 lines (1603 loc) · 81.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="theme-next muse use-motion" lang>
<head><meta name="generator" content="Hexo 3.8.0">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">
<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">
<link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">
<meta name="keywords" content="Hexo, NexT">
<meta property="og:type" content="website">
<meta property="og:title" content="LeeywBlog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="LeeywBlog">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="LeeywBlog">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Muse',
version: '5.1.4',
sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
fancybox: true,
tabs: true,
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
duoshuo: {
userId: '0',
author: 'Author'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="http://yoursite.com/">
<title>LeeywBlog</title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="default">
<div class="container sidebar-position-left
page-home">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">LeeywBlog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">我的学习笔记</p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br>
Home
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
Archives
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/30/how-to-install-node-sass/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Leeyw">
<meta itemprop="description" content>
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="LeeywBlog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/05/30/how-to-install-node-sass/" itemprop="url">how-to-install-node-sass</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2019-05-30T17:50:54+08:00">
2019-05-30
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="plan-1"><a href="#plan-1" class="headerlink" title="plan 1:"></a>plan 1:</h2><p> 在<em>macOS</em>或者<em>Window</em>已经配置了<strong>git</strong>在<strong>git bash窗口</strong>的条件下<strong>直接执行</strong>命令:</p>
<pre><code>//使用淘宝镜像
SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass
</code></pre><p><strong><em>若你的window没有git环境</em></strong><br>则依次执行:</p>
<pre><code>set SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/
npm install node-sass
</code></pre><h2 id="plan-2:"><a href="#plan-2:" class="headerlink" title="plan 2:"></a>plan 2:</h2><p>在你的project下创建一个 <strong>.npmrc</strong> 文件<br>在文件中<strong>添加</strong> <code>sass_binary_site=https://npm.taobao.org/mirrors/node-sass/</code><br>再执行 <code>npm -g install node-sass</code></p>
<p>以上安装成功后使用<code>node-sass -v</code> 测试安装是否成功</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/29/why-useing-clearfix/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Leeyw">
<meta itemprop="description" content>
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="LeeywBlog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/05/29/why-useing-clearfix/" itemprop="url">解决CSS的定位方案!(clearfix)</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2019-05-29T20:44:55+08:00">
2019-05-29
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="前置知识"><a href="#前置知识" class="headerlink" title="前置知识"></a>前置知识</h1><h2 id="一般我们使用那些定位?"><a href="#一般我们使用那些定位?" class="headerlink" title="一般我们使用那些定位?"></a>一般我们使用那些定位?</h2><h4 id="1-staic-普通定位流-默认"><a href="#1-staic-普通定位流-默认" class="headerlink" title="1. staic(普通定位流/默认)"></a>1. staic(普通定位流/默认)</h4><ul>
<li>block || inline 从上到下 || 从左到右排列布局</li>
</ul>
<h4 id="2-float-浮动定位"><a href="#2-float-浮动定位" class="headerlink" title="2. float(浮动定位)"></a>2. float(浮动定位)</h4><ul>
<li>value:(none/left/right)</li>
<li>会脱离文档流,但仍然属于父元素</li>
</ul>
<h4 id="3-position"><a href="#3-position" class="headerlink" title="3. position"></a>3. position</h4><ul>
<li><p>value:(relative/absolute/fixed/sticky)</p>
<blockquote>
<p>relative</p>
<blockquote>
<p>相对原位置偏移某些距离,但仍然占据原位置的空间<br>不脱离文档流(或许?,因为偏移了以后仍然占据原空间)</p>
</blockquote>
</blockquote>
<blockquote>
<p>absolute</p>
<blockquote>
<p>寻找父元素的relative,一直向上找青蛙,直到(html/body)<br>脱离文档流</p>
</blockquote>
</blockquote>
<blockquote>
<p>fixed</p>
<blockquote>
<p>将element固定在窗口的某个相对位置,不随着滚动条的位置变化而变化<br>脱离文档流</p>
</blockquote>
</blockquote>
<h2 id="注意!"><a href="#注意!" class="headerlink" title="注意!"></a>注意!</h2><h4 id="0-浮动定位解决的问题多个块级元素在同一行显示"><a href="#0-浮动定位解决的问题多个块级元素在同一行显示" class="headerlink" title="0. 浮动定位解决的问题多个块级元素在同一行显示"></a>0. 浮动定位解决的问题多个块级元素在同一行显示</h4><h4 id="1-block-element允许修改尺寸,inline-不允许修改尺寸"><a href="#1-block-element允许修改尺寸,inline-不允许修改尺寸" class="headerlink" title="1. block element允许修改尺寸,inline 不允许修改尺寸"></a>1. block element允许修改尺寸,inline 不允许修改尺寸</h4><h4 id="2-若“一行”内显示不下所有float内容last-element则会换行"><a href="#2-若“一行”内显示不下所有float内容last-element则会换行" class="headerlink" title="2. 若“一行”内显示不下所有float内容last element则会换行"></a>2. 若“一行”内显示不下所有float内容last element则会换行</h4><h4 id="3-block-or-inline-or-inline-block-再浮动后都会变成block"><a href="#3-block-or-inline-or-inline-block-再浮动后都会变成block" class="headerlink" title="3. block or inline or inline-block 再浮动后都会变成block"></a>3. block or inline or inline-block 再浮动后都会变成block</h4><hr>
<h1 id="正片-如何清除浮动-or-闭合浮动?"><a href="#正片-如何清除浮动-or-闭合浮动?" class="headerlink" title="正片! 如何清除浮动 or 闭合浮动?"></a>正片! 如何清除浮动 or 闭合浮动?</h1><h4 id="Q-为什么浮动这么好却要-清除(闭合)浮动"><a href="#Q-为什么浮动这么好却要-清除(闭合)浮动" class="headerlink" title="Q: 为什么浮动这么好却要 清除(闭合)浮动?"></a>Q: 为什么浮动这么好却要 <del>清除</del>(闭合)浮动?</h4><h4 id="A"><a href="#A" class="headerlink" title="A:"></a>A:</h4><hr>
<h4 id="1-clear-:-译为清除,以下取值详解"><a href="#1-clear-:-译为清除,以下取值详解" class="headerlink" title="1. clear : 译为清除,以下取值详解"></a>1. clear : 译为清除,以下取值详解</h4><h4 id="2-闭合浮动:使浮动元素“闭合”减少浮动带来的影响"><a href="#2-闭合浮动:使浮动元素“闭合”减少浮动带来的影响" class="headerlink" title="2. 闭合浮动:使浮动元素“闭合”减少浮动带来的影响"></a>2. 闭合浮动:使浮动元素“闭合”减少浮动带来的影响</h4></li>
</ul>
<hr>
<h4 id="plan-1:给父元素添加空子元素(after),设置clear-both-简单点说就是添加额外的标签"><a href="#plan-1:给父元素添加空子元素(after),设置clear-both-简单点说就是添加额外的标签" class="headerlink" title="plan 1:给父元素添加空子元素(after),设置clear:both,简单点说就是添加额外的标签"></a>plan 1:给父元素添加空子元素(after),设置clear:both,简单点说就是添加额外的标签</h4><ul>
<li>clear:none 默认,不做任何操作</li>
<li>clear:left 清除前面元素带来的所有左浮动影响</li>
<li>clear:float 和楼上类似效果</li>
<li>clear:both 清除前面元素所有浮动带来的影响</li>
</ul>
<p><strong>优势</strong>:代码量少,易学,好懂<br><strong>劣势</strong>:推荐</p>
<pre><code>.clearfix::after{
content: ''; //添加空元素
display: block;//设置成块级元素
clear: both;//清除前面浮动带来的所有效果
}
</code></pre><h4 id="plan-2-添加-gt-标签,通过其本身HTML特性"><a href="#plan-2-添加-gt-标签,通过其本身HTML特性" class="headerlink" title="plan 2: 添加>标签,通过其本身HTML特性"></a>plan 2: 添加<br clear="both">>标签,通过其本身HTML特性</h4><ul>
<li>在浮动元素的父元素下添加一个last child 标签为<br clear="both"></li>
<li>OK!</li>
<li></li>
</ul>
<p><strong>优势</strong>: 代码量更少<br><strong>劣势</strong>:同有违结构和表现的分离,不推荐</p>
<h4 id="plan-3-添加-overflow-hidden"><a href="#plan-3-添加-overflow-hidden" class="headerlink" title="plan 3:添加 overflow:hidden;"></a>plan 3:添加 overflow:hidden;</h4><ul>
<li>在浮动元素的父元素下添加CSS样式 overflow:hidden</li>
</ul>
<p><strong>优势</strong>:代码量更更少了<br><strong>劣势</strong>:内容增多会造成不会自动换行导致内容被隐藏,无法显示要溢出的内容<br>注意:(这个bug写者并没有实验出来),但既然已经有人排过雷便少使用此方法罢。</p>
<h4 id="plan-3-添加-overflow-auto"><a href="#plan-3-添加-overflow-auto" class="headerlink" title="plan 3:添加 overflow:auto;"></a>plan 3:添加 overflow:auto;</h4><ul>
<li>在浮动元素的父元素下添加CSS样式 overflow:auto</li>
</ul>
<p><strong>优势</strong>:代码量更更更少了…<br><strong>劣势</strong>:冒失雷挺多的,不要使用</p>
<h4 id="plan-5-添加-display-table"><a href="#plan-5-添加-display-table" class="headerlink" title="plan 5:添加 display:table;"></a>plan 5:添加 display:table;</h4><ul>
<li>在浮动元素的父元素下添加CSS样式 display:table;</li>
</ul>
<p><strong>优势</strong>:代码量… 懂的<br><strong>劣势</strong>:盒模型属性改变,造成的影响可能比带来的好处要大,不推荐</p>
<h3 id="小结:"><a href="#小结:" class="headerlink" title="小结:"></a>小结:</h3><ul>
<li>推荐Plan 1</li>
<li><p>“闭合”浮动无非是两种方法:</p>
<blockquote>
<ol>
<li>通过在浮动元素末尾添加一个元素 然后clear:both</li>
<li>通过overflow or display:table 闭合浮动</li>
</ol>
</blockquote>
</li>
<li><p>如何理解其中原理 便看我另一篇文章《(Block formatting contexts)BFS是啥子?》</p>
</li>
</ul>
<pre><code>参考资料:
</code></pre><ul>
<li><a href="http://www.iyunlu.com/view/css-xhtml/55.html" target="_blank" rel="noopener">《那些年我们一起清除过的浮动》</a></li>
<li><a href="https://cloud.tencent.com/developer/article/1438265" target="_blank" rel="noopener">《清除浮动的多种方式》</a></li>
<li><a href="https://www.w3schools.com/cssref/pr_class_clear.asp" target="_blank" rel="noopener">Css clear Property</a></li>
<li><a href="https://developer.mozilla.org/zh-CN/docs/CSS/float" target="_blank" rel="noopener">Css float Property</a></li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/23/newPromise-async/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Leeyw">
<meta itemprop="description" content>
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="LeeywBlog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/05/23/newPromise-async/" itemprop="url">newPromise-async</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2019-05-23T21:45:57+08:00">
2019-05-23
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="new-Promise-async"><a href="#new-Promise-async" class="headerlink" title="new Promise(async)"></a>new Promise(async)</h1><h2 id="承诺执行"><a href="#承诺执行" class="headerlink" title="承诺执行"></a>承诺执行</h2><h2 id="then"><a href="#then" class="headerlink" title="then"></a>then</h2><h2 id="catch"><a href="#catch" class="headerlink" title="catch"></a>catch</h2><h2 id="async-resolve-reject"><a href="#async-resolve-reject" class="headerlink" title="async(resolve,reject){"></a>async(resolve,reject){</h2><p>//TODO<br>}</p>
<h2 id="on-resolve-data"><a href="#on-resolve-data" class="headerlink" title="on_resolve(data){"></a>on_resolve(data){</h2><p>//“成功”TODO<br>}</p>
<h2 id="on-reject-data"><a href="#on-reject-data" class="headerlink" title="on_reject(data){"></a>on_reject(data){</h2><p>//“失败”TODO<br>}</p>
<p><em>XMind: ZEN - Trial Version</em></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/21/CreateFreeCloudServer/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Leeyw">
<meta itemprop="description" content>
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="LeeywBlog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/05/21/CreateFreeCloudServer/" itemprop="url">CreateFreeCloudServer</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2019-05-21T23:31:46+08:00">
2019-05-21
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="在你的网页上创建一个免费的数据库-leancloud"><a href="#在你的网页上创建一个免费的数据库-leancloud" class="headerlink" title="在你的网页上创建一个免费的数据库(leancloud)"></a>在你的网页上创建一个免费的数据库(leancloud)</h1><h2 id="1-注册账号"><a href="#1-注册账号" class="headerlink" title="1.注册账号"></a>1.<a href="https://leancloud.cn/dashboard/login.html#/signup" target="_blank" rel="noopener">注册账号</a></h2><h2 id="2-创建应用"><a href="#2-创建应用" class="headerlink" title="2. 创建应用"></a>2. 创建应用</h2><h2 id="3-进入快速入门页面选择你的主要编译语言"><a href="#3-进入快速入门页面选择你的主要编译语言" class="headerlink" title="3. 进入快速入门页面选择你的主要编译语言"></a>3. 进入<a href="https://leancloud.cn/docs/start.html" target="_blank" rel="noopener">快速入门</a>页面选择你的主要编译语言</h2><h2 id="4-下载-or-引入-服务"><a href="#4-下载-or-引入-服务" class="headerlink" title="4. 下载 or 引入 服务"></a>4. 下载 or 引入 服务</h2><pre><code><script src="//cdn.jsdelivr.net/npm/[email protected]/dist/av-min.js"></script>
</code></pre><h2 id="5-init"><a href="#5-init" class="headerlink" title="5. init"></a>5. init</h2><pre><code>var APP_ID = 'you APP_ID';
var APP_KEY = 'you APP_KEY';
AV.init({
appId: APP_ID,
appKey: APP_KEY
});
</code></pre><h2 id="6-验证"><a href="#6-验证" class="headerlink" title="6. 验证"></a>6. 验证</h2><pre><code>ping "kdqicvul.api.lncld.net"
and
/.js
var TestObject = AV.Object.extend('TestObject');var testObject = new TestObject();
testObject.save({
words: 'Hello World!'}).then(function(object) {
alert('LeanCloud Rocks!');})
</code></pre><h2 id="7-获取后端数据?查看API文档"><a href="#7-获取后端数据?查看API文档" class="headerlink" title="7. 获取后端数据?查看API文档"></a>7. 获取后端数据?查看API文档</h2>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/18/Browser-Same-origin-policy-EvaSion-Method/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Leeyw">
<meta itemprop="description" content>
<meta itemprop="image" content="/images/avatar.gif">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="LeeywBlog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/05/18/Browser-Same-origin-policy-EvaSion-Method/" itemprop="url">Browser-Same-origin-policy-EvaSion-Method</a></h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Post created" itemprop="dateCreated datePublished" datetime="2019-05-18T13:47:21+08:00">
2019-05-18
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="浏览器同源政策以及规避方法"><a href="#浏览器同源政策以及规避方法" class="headerlink" title="浏览器同源政策以及规避方法"></a>浏览器同源政策以及规避方法</h1><blockquote>
<p>浏览器安全的基石是”同源政策”(same-origin policy)</p>
</blockquote>
<h2 id="一、简介"><a href="#一、简介" class="headerlink" title="一、简介"></a>一、简介</h2><blockquote>
<p>同源政策为Netscape公司于1995年引入浏览器。<br>目前,所有浏览器都实行这个政策</p>
</blockquote>
<h3 id="1)含义"><a href="#1)含义" class="headerlink" title="1)含义"></a>1)含义</h3><blockquote>
<p>“同源”</p>
<blockquote>
<p>A网页设置Cookie,B网页不能打开,除非“同源”</p>
</blockquote>
</blockquote>
<ul>
<li>“同源”三同:<ol>
<li>协议相同</li>
<li>域名相同</li>
<li>端口相同</li>
</ol>
</li>
</ul>
<blockquote>
<p>目的</p>
<blockquote>
<p>保证Client信息安全,防止被恶意窃取数据。<br>例如:<br>用户C访问网站A,用户登陆后又去访问网站B(恶意网站),若网站B可读取A网站Cookie?</p>
<ol>
<li>B网站通过Cookie获取到用户C的信息(若Cookie包含隐私,则会隐私泄露)</li>
<li>由于Cookie往往是来保存登陆信息,若用户没有退出登陆,则网站B可以冒充用户:为所欲为。浏览器规定:提交表单不受同源政策限制<br>综上所述<br>同源政策是必须的,“同源政策”越严格,用户安全性更高,网站安全性更高。(防止Cookie共享)</li>
</ol>
</blockquote>
</blockquote>
<blockquote>
<p>限制范围</p>
<blockquote>
<p>若非“同源”,则 共有三种行为限制</p>
</blockquote>
</blockquote>
<ul>
<li>Cookie,LocalStorage 和 IndexDB 无法读取</li>
<li>DOM无法获得</li>
<li><p>AJAX请求无法发送</p>
<p>虽然这些限制是必要的,但是有时很不方便,合理的用途也受到影响。下述将如何规避这些限制</p>
</li>
</ul>
<h2 id="二、Cookie"><a href="#二、Cookie" class="headerlink" title="二、Cookie"></a>二、Cookie</h2><blockquote>
<p>Cookie是Server给Browser的一段信息,只有“同源”网页才能共享 但有时同属网页下,会出现一级域名相同二级域名不同的情况?<br>不同的网页通过设置相同的document.domain来共享Cookie</p>
</blockquote>
<pre><code>document.domain = "example.com"
</code></pre><p>所以现在网页A通过脚本设置一个Cookie</p>
<pre><code>documenet.cookie = "test = lwh"
</code></pre><p> 网页B就可以读取到这个Cookie</p>
<pre><code>var allCookie = document.cookie
</code></pre><blockquote>
<p>这种方法只适用于Cookie以及iframe窗口,LocalStorage以及IndexDB无法通过这种方法,规避“同源政策”,就需要使用PostMessage API</p>
</blockquote>
<blockquote>
<p>另外:Server在设置Cookie时,指定Cookie的所属域名为y一级域名,例如,.example.com</p>
</blockquote>
<pre><code>Set-Cookie:key=value;domain=.example.com;path = /
此后下属,二/三级域名不用做任何设置都可以读取这个Cookie
</code></pre><h2 id="三、iframe"><a href="#三、iframe" class="headerlink" title="三、iframe"></a>三、iframe</h2><blockquote>
<p>两个网页不同源,则无法获取到对方DOM</p>
<blockquote>
<p>例子:<br>iframe 以及 window.open 打开的窗口都无法与父窗口通信</p>
</blockquote>
</blockquote>
<pre><code>强行访问则会报错
// Uncaught DOMException: Blocked a frame from accessing a cross-origin frame.
未捕获,DOM异常:阻止了一个frame访问跨源frame
无论子访问父or父访问子的DOM 都会报错
</code></pre><blockquote>
<p>三种方法解决跨域访问的通信问题</p>
<pre><code>1. 片段识别符(fragment identifier)
2. window.name
3. 跨文档通信API(Cross-document messaging)
</code></pre></blockquote>
<ul>
<li><ol>
<li><p>片段识别符(fragment identifier)</p>
<blockquote>
<p>URL # 号后面部分例如:<br><a href="http://example.com/x.html#fragment的fragment就是偏度识别符,改变片段识别符,页面不会重新刷新" target="_blank" rel="noopener">http://example.com/x.html#fragment的fragment就是偏度识别符,改变片段识别符,页面不会重新刷新</a></p>
<blockquote>
<p>父窗口可以把信息写入子窗口的片段识别符</p>
</blockquote>
</blockquote>
<pre><code>var src = originURL + '#' + data;
document.getElementById('myIFrame').src = src;
</code></pre><blockquote>
<blockquote>
<p>子窗口通过 监听 hashchange 事件得到通知</p>
</blockquote>
</blockquote>
</li>
</ol>
</li>
</ul>
<pre><code>window.onhashchange = checkMessage;
function checkMessage() {
var message = window.location.hash;
// ...
}
</code></pre><blockquote>
<blockquote>
<p>同时,子窗口也可以改变父窗口的片段标识</p>
</blockquote>
</blockquote>
<pre><code>parent.location.href= target + "#" + hash;
</code></pre><ul>
<li><ol start="2">