-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path箭头函数中的-this.html
497 lines (332 loc) · 27.5 KB
/
箭头函数中的-this.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>箭头函数中的 this-Over the mountains, mountains. | 空脑壳</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/x-icon" href="https://myblog-static.oss-cn-beijing.aliyuncs.com/favor-icon/mylogo.png">
<meta name="keywords" content="雷雷雷,空脑壳,前端,HTML,CSS,JS,生活" />
<meta name="google-site-verification" content="pTRbturh_lAK5OIXLwAO7OKRMaEgSX2MtqqFrk1AMRM" />
<meta name="baidu-site-verification" content="vyp41u64K8" />
<meta name="description" content="箭头函数中的 this 是在定义的时候定义好的,如果当前作用域找不到 this 则向上查找直到找到为止。">
<meta name="keywords" content="javascript">
<meta property="og:type" content="article">
<meta property="og:title" content="箭头函数中的 this">
<meta property="og:url" content="http://hi.thisisray.me/箭头函数中的-this.html">
<meta property="og:site_name" content="空脑壳">
<meta property="og:description" content="箭头函数中的 this 是在定义的时候定义好的,如果当前作用域找不到 this 则向上查找直到找到为止。">
<meta property="og:locale" content="en">
<meta property="og:updated_time" content="2018-10-08T03:26:35.145Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="箭头函数中的 this">
<meta name="twitter:description" content="箭头函数中的 this 是在定义的时候定义好的,如果当前作用域找不到 this 则向上查找直到找到为止。">
<link rel="alternate" href="/atom.xml" title="空脑壳" type="application/atom+xml">
<link rel="apple-touch-icon" href="/https://myblog-static.oss-cn-beijing.aliyuncs.com/favor-icon/avatar.jpg">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<style type="text/css">
@font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");font-weight:500;font-style:normal;}
@font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");font-weight:500;font-style:normal;}
@font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");font-weight:lighter;font-style:normal;}
@font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");font-weight:400;font-style:italic;}</style>
<link rel="stylesheet" href="/css/style.css">
<script src="/js/jquery-3.1.1.min.js"></script>
<script src="/js/bootstrap.js"></script>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="/css/bootstrap.css" >
<link rel="stylesheet" href="/css/dialog.css">
<link rel="stylesheet" href="/css/header-post.css" >
<link rel="stylesheet" href="/css/vdonate.css" >
</head>
<body data-spy="scroll" data-target="#toc" data-offset="50">
<div id="container">
<div id="wrap">
<header>
<div id="allheader" class="navbar navbar-default navbar-static-top" role="navigation">
<div class="navbar-inner">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" style="
margin-top: 0px;"
href="#" data-toggle="modal" data-target="#myModal" >
<img width="124px" height="124px" alt="Hike News" src="https://myblog-static.oss-cn-beijing.aliyuncs.com/favor-icon/avatar.jpg">
</a>
<div class="navbar-collapse collapse">
<ul class="hnav navbar-nav">
<li> <a class="main-nav-link" href="/">Home</a> </li>
<li> <a class="main-nav-link" href="/archives">Archives</a> </li>
<li> <a class="main-nav-link" href="/categories">Categories</a> </li>
<li> <a class="main-nav-link" href="/tags">Tags</a> </li>
<li><div id="search-form-wrap">
<form class="search-form">
<input type="text" class="ins-search-input search-form-input" placeholder="" />
<button type="submit" class="search-form-submit"></button>
</form>
<div class="ins-search">
<div class="ins-search-mask"></div>
<div class="ins-search-container">
<div class="ins-input-wrapper">
<input type="text" class="ins-search-input" placeholder="Type something..." />
<span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
</div>
<div class="ins-section-wrapper">
<div class="ins-section-container"></div>
</div>
</div>
</div>
<script>
(function (window) {
var INSIGHT_CONFIG = {
TRANSLATION: {
POSTS: 'Posts',
PAGES: 'Pages',
CATEGORIES: 'Categories',
TAGS: 'Tags',
UNTITLED: '(Untitled)',
},
ROOT_URL: '/',
CONTENT_URL: '/content.json',
};
window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/js/insight.js"></script>
</div></li>
</div>
</div>
</div>
</div>
</header>
<div id="content" class="outer">
<section id="main" style="float:none;"><article id="posrt-箭头函数中的-this" style="width: 75%; float:left;" class="article article-type-posrt article-home-false" itemscope itemprop="blogPost" >
<div id="articleInner" class="article-inner">
<header class="article-header">
<h1 class="thumb" class="article-title" itemprop="name">
箭头函数中的 this
</h1>
</header>
<div class="article-meta">
<a href="/箭头函数中的-this.html" class="article-date">
<time datetime="2018-03-01T06:45:00.000Z" itemprop="datePublished">2018-03-01</time>
</a>
<a class="article-category-link" href="/categories/烂笔头/">烂笔头</a>
</div>
<div class="article-count">
<div class="count-wrapper">
<span class="post-count">本文共 1,218 字</span>
<span class="post-count">预计花费 5 分钟</span>
</div>
</div>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p>箭头函数中的 <code>this</code> 是在定义的时候定义好的,如果当前作用域找不到 <code>this</code> 则向上查找直到找到为止。</p>
</blockquote>
<a id="more"></a>
<p><strong><em>转自:<a href="https://github.com/zhengweikeng/blog/blob/master/posts/2016/%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0%E4%B8%ADthis%E7%9A%84%E7%94%A8%E6%B3%95.md" target="_blank" rel="noopener">箭头函数中this的用法.md</a> 版权归原作者所有</em></strong></p>
<blockquote>
<p>es6中有一种新的定义函数的形式,称之为arrow function,即箭头函数。其带来了很多便捷性,本文不打算阐述arrow function带来的好处,而是想来说说它的this。</p>
</blockquote>
<p>学习javascript的人,一般来说会遇到两道坎,其中一道是原型链,另一道可能就是this问题了。js的函数不断变化的this经常让人无法摸不着头脑,很多时候我们会使用bind、call、apply来强制指定函数的this。</p>
<p>本文假设你已经掌握了js中的this问题了,如果你不懂,可以访问如下链接,了解下js中的this问题</p>
<p><a href="http://www.cnblogs.com/isaboy/archive/2015/10/29/javascript_this.html" target="_blank" rel="noopener">图解javascript this指向什么?</a></p>
<h3 id="词法作用域"><a href="#词法作用域" class="headerlink" title="词法作用域"></a>词法作用域</h3><p>Arrow Function中的this机制和一般的函数是不一样的。<br>本质来说Arrow Function并没有自己的this,它的this是派生而来的,根据“词法作用域”派生而来。</p>
<p>因此Arrow Function中的this是遵守“词法作用域”的</p>
<p>什么是词法作用域?</p>
<p>一般来说,作用域有两种常见的模型,一种叫做词法作用域(Lexical Scope),一种叫做动态作用域(Dynamic Scope)。而javascript采取的便是词法作用域</p>
<p>简单来说,所谓的词法作用域就是一个变量的作用在定义的时候就已经被定义好,当在本作用域中找不到变量,就会一直向父作用域中查找,直到找到为止。</p>
<p>说到这一点,我相信大家都明白了,不明白?上个例子<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">fn</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="keyword">var</span> a = <span class="string">'hello'</span></span><br><span class="line"> <span class="keyword">var</span> b = <span class="string">'javascript'</span></span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="keyword">function</span> <span class="title">innerFn</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="keyword">var</span> b = <span class="string">'world'</span></span><br><span class="line"> <span class="built_in">console</span>.log(<span class="string">`<span class="subst">${a}</span> <span class="subst">${b}</span>`</span>)</span><br><span class="line"> }</span><br><span class="line"> innerFn()</span><br><span class="line">}</span><br><span class="line">fn() <span class="comment">// hello world</span></span><br></pre></td></tr></table></figure></p>
<p>因为在innerFn中已经定义了b所以,因此在查找b时便不会去使用父作用域中的b了。</p>
<p>Arrow Function中的this便遵循了这个含义</p>
<h3 id="Arrow-Function中的this"><a href="#Arrow-Function中的this" class="headerlink" title="Arrow Function中的this"></a>Arrow Function中的this</h3><p>先来看一个案例<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">taskA</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="keyword">this</span>.name = <span class="string">'hello'</span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">var</span> fn = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>)</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>.name)</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">var</span> arrow_fn = <span class="function"><span class="params">()</span> =></span> {</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>)</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>.name)</span><br><span class="line"> }</span><br><span class="line"> fn()</span><br><span class="line"> arrow_fn()</span><br><span class="line">}</span><br><span class="line">taskA()</span><br></pre></td></tr></table></figure></p>
<p>最终我们会发现,两个内部函数的this都是window,而且this.name都是hello。</p>
<p>好像没什么区别。其实两个函数的this的产生流程是不一样的。</p>
<p>fn的this是在运行时产生的,由于我们是直接调用fn(),所以其this就是指向window。如果将其调用改成<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">taskA</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="keyword">this</span>.name = <span class="string">'hello'</span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">var</span> fn = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>)</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>.name)</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">var</span> obj = {</span><br><span class="line"> name: <span class="string">'haha'</span>,</span><br><span class="line"> fn: fn</span><br><span class="line"> }</span><br><span class="line"> obj.fn()</span><br><span class="line">}</span><br><span class="line">taskA()</span><br></pre></td></tr></table></figure></p>
<p>这时this就是obj对象,name是haha。这个符合我们对一般函数this的理解。</p>
<p>接下来看看Arrow Function中的this。它是怎么产生的呢,首先根据“词法作用域”,由于它本身没有this,于是便向上查找this,于是发现taskA是有this的,于是便直接继承了taskA的作用域。</p>
<p>那taskA的this又是什么?很简单,taskA是一个普通的函数,普通函数的this是在运行时决定的,由于我们是直接调用taskA的,即taskA(),所以其this便是window。</p>
<p>这下我们便明白了,arrow_fn中的this是window的原因了。我们稍微修改下案例<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">taskA</span>(<span class="params"></span>) </span>{</span><br><span class="line"> <span class="keyword">var</span> arrow_fn = <span class="function"><span class="params">()</span> =></span> {</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>)</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>.name)</span><br><span class="line"> }</span><br><span class="line"> arrow_fn()</span><br><span class="line">}</span><br><span class="line"><span class="keyword">var</span> obj = {<span class="attr">name</span>: <span class="string">'Jack'</span>}</span><br><span class="line">taskA.bind(obj)()</span><br></pre></td></tr></table></figure></p>
<p>这时候,Arrow Function中的this便变成了obj对象了,name便是Jack。</p>
<p>可能有人会说,不是说Arrow Function中的this是定义的时候就决定了么,怎么现在又变成了运行的时候决定了呢。</p>
<p>Arrow Function中的this是定义的时候就决定的,这句话是对的。</p>
<p>该案例中,Arrow Function中,即arrow_fn的this便是taskA的this,在定义这个arrow_fn时候便决定了,于是又回到了上面说的,taskA是一个普通的函数,普通函数的this是在运行时决定的,而此时由于bind的原因,taskA的this已经变为obj,因此arrow_fnd的this便是obj了。</p>
<p>说到这里,相信大家应该已经明白了Arrow Function的this的含义和具体指向了。</p>
<p>所以我们才说Arrow Function的this是遵守“词法作用域”的。</p>
<h3 id="其他案例"><a href="#其他案例" class="headerlink" title="其他案例"></a>其他案例</h3><p>我们再来看看其他案例<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> obj = {</span><br><span class="line"> field: <span class="string">'hello'</span>,</span><br><span class="line"> getField: <span class="function"><span class="params">()</span> =></span> {</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>.field)</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line">obj.getField() <span class="comment">// undefined</span></span><br></pre></td></tr></table></figure></p>
<p>这里最终会打出undefined,因为getField中的this就是window,而window是没有field这个属性的,所以就是undefined了。</p>
<p>所以我们一般不建议对象中定义函数的时候使用Arrow Function,毕竟this就会造成错误了。所以应该这么写<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> obj = {</span><br><span class="line"> field: <span class="string">'hello'</span>,</span><br><span class="line"> getField(){</span><br><span class="line"> <span class="built_in">console</span>.log(<span class="keyword">this</span>.field)</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure></p>
<p>这样this就是obj了。</p>
</div>
<footer class="article-footer">
<div id="donation_div"></div>
<script src="/js/vdonate.js"></script>
<script>
var a = new Donate({
title: '水平有限,喝杯咖啡交个朋友吧。', // 可选参数,打赏标题
btnText: 'Donate', // 可选参数,打赏按钮文字
el: document.getElementById('donation_div'),
wechatImage: 'https://myblog-static.oss-cn-beijing.aliyuncs.com/Donate/wechat.png?x-oss-process=style/blogImg-watermark',
alipayImage: 'https://myblog-static.oss-cn-beijing.aliyuncs.com/Donate/alipay.jpg?x-oss-process=style/blogImg-watermark'
});
</script>
<div id="comment">
<!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC8yOTQ4MS82MDQ5">
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
<!-- City版安装代码已完成 -->
</div>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/javascript/">javascript</a></li></ul>
</footer>
</div>
<nav id="article-nav">
<a href="/reflow(重排)-和-repaint(重绘).html" id="article-nav-newer" class="article-nav-link-wrap">
<strong class="article-nav-caption">Newer</strong>
<div class="article-nav-title">
reflow(重排) 和 repaint(重绘)
</div>
</a>
<a href="/CSS3-linear-gradient-全兼容.html" id="article-nav-older" class="article-nav-link-wrap">
<strong class="article-nav-caption">Older</strong>
<div class="article-nav-title">CSS3 linear-gradient 全兼容</div>
</a>
</nav>
</article>
<!-- Table of Contents -->
<aside id="toc-sidebar">
<div id="toc" class="toc-article">
<strong class="toc-title">Contents</strong>
<ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#词法作用域"><span class="nav-number">1.</span> <span class="nav-text">词法作用域</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Arrow-Function中的this"><span class="nav-number">2.</span> <span class="nav-text">Arrow Function中的this</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#其他案例"><span class="nav-number">3.</span> <span class="nav-text">其他案例</span></a></li></ol>
</div>
</aside>
</section>
</div>
<footer id="footer">
<div class="container">
<div class="row">
<!-- <p> Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/iTimeTraveler/hexo-theme-hiker" target="_blank">Hexo-theme-hiker</a> </p> -->
<p id="copyRightEn">Copyright © 2017 - 2018 空脑壳 All Rights Reserved.</p>
<p>冀ICP备17022284号</p>
</div>
</div>
</footer>
<!-- min height -->
<script>
var wrapdiv = document.getElementById("wrap");
var contentdiv = document.getElementById("content");
var allheader = document.getElementById("allheader");
wrapdiv.style.minHeight = document.body.offsetHeight + "px";
if (allheader != null) {
contentdiv.style.minHeight = document.body.offsetHeight - allheader.offsetHeight - document.getElementById("footer").offsetHeight + "px";
} else {
contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("footer").offsetHeight + "px";
}
</script>
</div>
<!-- <nav id="mobile-nav">
<a href="/" class="mobile-nav-link">Home</a>
<a href="/archives" class="mobile-nav-link">Archives</a>
<a href="/categories" class="mobile-nav-link">Categories</a>
<a href="/tags" class="mobile-nav-link">Tags</a>
</nav> -->
<!-- mathjax config similar to math.stackexchange -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script src="/js/scripts.js"></script>
<script src="/js/dialog.js"></script>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="myModalLabel">设置</h2>
</div>
<hr style="margin-top:0px; margin-bottom:0px; width:80%; border-top: 3px solid #000;">
<hr style="margin-top:2px; margin-bottom:0px; width:80%; border-top: 1px solid #000;">
<div class="modal-body">
<div style="margin:6px;">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" onclick="javascript:setFontSize();" aria-expanded="true" aria-controls="collapseOne">
正文字号大小
</a>
</div>
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
您已调整页面字体大小
</div>
</div>
<div style="margin:6px;">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" onclick="javascript:setBackground();" aria-expanded="true" aria-controls="collapseTwo">
夜间护眼模式
</a>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
夜间模式已经开启,再次单击按钮即可关闭
</div>
</div>
<div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="true" aria-controls="collapseThree"> 关 于 </a>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
空脑壳
</div>
<div class="panel-body">
Copyright © 2018 雷雷雷 All Rights Reserved.
</div>
</div>
</div>
<hr style="margin-top:0px; margin-bottom:0px; width:80%; border-top: 1px solid #000;">
<hr style="margin-top:2px; margin-bottom:0px; width:80%; border-top: 3px solid #000;">
<div class="modal-footer">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
</div>
</div>
</div>
<a id="rocket" href="#top" class=""></a>
<script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
<a id="menu-switch"><i class="fa fa-bars fa-lg"></i></a>
</body>
</html>