-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
966 lines (622 loc) · 63.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 5.4.2">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" integrity="sha256-Z1K5uhUaJXA7Ll0XrZ/0JhX4lAtZFpT6jkKrEDT0drU=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.14.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}}</script><script src="/js/config.js"></script>
<meta property="og:type" content="website">
<meta property="og:title" content="menger's blog">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="menger's blog">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="meng-er">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="http://example.com/">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"en","comments":"","permalink":"","path":"index.html","title":""}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>menger's blog</title>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<div class="column">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="Toggle navigation bar" role="button">
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<h1 class="site-title">menger's blog</h1>
<i class="logo-line"></i>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger" aria-label="Search" role="button">
</div>
</div>
</div>
</header>
<aside class="sidebar">
<div class="sidebar-inner sidebar-overview-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
Table of Contents
</li>
<li class="sidebar-nav-overview">
Overview
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<p class="site-author-name" itemprop="name">meng-er</p>
<div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">8</span>
<span class="site-state-item-name">posts</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<span class="site-state-item-count">2</span>
<span class="site-state-item-name">tags</span>
</div>
</nav>
</div>
</div>
</div>
</div>
</aside>
</div>
<div class="main-inner index posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2023/02/02/hello-world/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/02/02/hello-world/" class="post-title-link" itemprop="url">Hello World</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2023-02-02 18:32:54" itemprop="dateCreated datePublished" datetime="2023-02-02T18:32:54+08:00">2023-02-02</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2023/02/01/vue3-axios%E5%AE%9E%E7%8E%B0%E5%89%8D%E5%90%8E%E7%AB%AF%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/02/01/vue3-axios%E5%AE%9E%E7%8E%B0%E5%89%8D%E5%90%8E%E7%AB%AF%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93/" class="post-title-link" itemprop="url">vue3+axios实现前后端数据传输</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2023-02-01 17:38:46 / Modified: 18:42:13" itemprop="dateCreated datePublished" datetime="2023-02-01T17:38:46+08:00">2023-02-01</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><strong>版本说明</strong></p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">"vue"</span><span class="punctuation">:</span> <span class="string">"^3.2.45"</span><span class="punctuation">,</span></span><br><span class="line"><span class="attr">"vue-router"</span><span class="punctuation">:</span> <span class="string">"^4.1.6"</span><span class="punctuation">,</span></span><br><span class="line"><span class="attr">"vite"</span><span class="punctuation">:</span> <span class="string">"^4.0.0"</span></span><br></pre></td></tr></table></figure>
<ul>
<li><h1 id="step1-设置跨域"><a href="#step1-设置跨域" class="headerlink" title="step1.设置跨域"></a>step1.设置跨域</h1></li>
</ul>
<p>在项目的根目录下新建<code>vite.config.ts</code>,写入如下代码</p>
<p>⚠️后缀名不是js、文件名也不是vue.config,vue.config.js是vue2的东西。</p>
<figure class="highlight js"><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><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> { defineConfig } <span class="keyword">from</span> <span class="string">'vite'</span></span><br><span class="line"><span class="keyword">import</span> vue <span class="keyword">from</span> <span class="string">'@vitejs/plugin-vue'</span></span><br><span class="line"><span class="keyword">import</span> vueJsx <span class="keyword">from</span> <span class="string">'@vitejs/plugin-vue-jsx'</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="title function_">defineConfig</span>({</span><br><span class="line"> <span class="attr">plugins</span>: [<span class="title function_">vue</span>(), <span class="title function_">vueJsx</span>()],</span><br><span class="line"> <span class="attr">server</span>: {</span><br><span class="line"> <span class="attr">open</span>: <span class="literal">true</span>, <span class="comment">//自动打开</span></span><br><span class="line"> <span class="attr">base</span>: <span class="string">"./ "</span>, <span class="comment">//生产环境路径</span></span><br><span class="line"> <span class="attr">proxy</span>: { </span><br><span class="line"> <span class="string">'^/api'</span>: {</span><br><span class="line"> <span class="attr">target</span>: <span class="string">'http://localhost:8080/'</span>, <span class="comment">// 后端服务实际地址</span></span><br><span class="line"> <span class="attr">changeOrigin</span>: <span class="literal">true</span>, <span class="comment">//开启代理</span></span><br><span class="line"> <span class="attr">rewrite</span>: <span class="function">(<span class="params">path</span>) =></span> path.<span class="title function_">replace</span>(<span class="regexp">/^\/api/</span>, <span class="string">''</span>)</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">})</span><br></pre></td></tr></table></figure>
<p>再逼逼赖赖两句:跨域是啥?为什么要跨域?</p>
<ul>
<li><h1 id="step2-把发送请求写到一个文件中"><a href="#step2-把发送请求写到一个文件中" class="headerlink" title="step2.把发送请求写到一个文件中"></a>step2.把发送请求写到一个文件中</h1></li>
</ul>
<p>为了方便维护,把所有请求写在一个文件中。</p>
<p>新建<code>project/src/api/user.ts</code></p>
<figure class="highlight js"><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></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="title class_">Axios</span> <span class="keyword">from</span> <span class="string">'axios'</span></span><br><span class="line"><span class="keyword">const</span> base = <span class="string">'http://localhost:5173/api'</span><span class="comment">//这个api随便替换成想要的名字,主要是从5173分一部分出去给服务器</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">Login</span> = (<span class="params">data: { [key: string]: any }</span>) => {</span><br><span class="line"> <span class="comment">//data是get请求的参数</span></span><br><span class="line"> <span class="keyword">return</span> <span class="title class_">Axios</span>.<span class="title function_">get</span>(base + <span class="string">'/login'</span>, { <span class="string">'params'</span>: data })</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> {</span><br><span class="line"> <span class="comment">//暴露出去,vue视图那边要用</span></span><br><span class="line"> base,</span><br><span class="line"> <span class="title class_">Login</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<ul>
<li><h1 id="step3-在vue视图层引用"><a href="#step3-在vue视图层引用" class="headerlink" title="step3.在vue视图层引用"></a>step3.在vue视图层引用</h1></li>
</ul>
<figure class="highlight js"><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><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> <span class="title function_">submitForm</span> = (<span class="params">formEl: FormInstance | <span class="literal">undefined</span></span>) => {</span><br><span class="line"> <span class="keyword">if</span> (!formEl) <span class="keyword">return</span></span><br><span class="line"> formEl.<span class="title function_">validate</span>(<span class="function">(<span class="params">valid</span>) =></span> {</span><br><span class="line"> <span class="keyword">if</span> (valid) {</span><br><span class="line"> <span class="comment">//🦦看这里看这里!是这在用</span></span><br><span class="line"> <span class="title class_">User</span>.<span class="title class_">Login</span>(</span><br><span class="line"> { <span class="attr">tel</span>: <span class="string">"13388110101"</span>, <span class="attr">password</span>: <span class="string">"123"</span> }</span><br><span class="line"> ).<span class="title function_">then</span>(<span class="function"><span class="params">res</span> =></span> {</span><br><span class="line"> <span class="comment">//把后端返回的数据打印下来</span></span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">'login response data'</span>, res)</span><br><span class="line"> })</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">'error submit!'</span>)</span><br><span class="line"> <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line"> }</span><br><span class="line"> })</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h1 id="后记"><a href="#后记" class="headerlink" title="后记"></a>后记</h1><p>当然,用get方法传输账号密码肯定是非常不科学的。不过这里的重点是跨域和发送请求、接收请求,就先浅浅忽视掉这个问题。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2023/02/01/elementui-input%E7%BB%84%E4%BB%B6%E4%B8%8D%E8%83%BD%E8%BE%93%E5%85%A5/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/02/01/elementui-input%E7%BB%84%E4%BB%B6%E4%B8%8D%E8%83%BD%E8%BE%93%E5%85%A5/" class="post-title-link" itemprop="url">elementui中input组件不能输入的问题</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2023-02-01 15:15:01 / Modified: 15:28:30" itemprop="dateCreated datePublished" datetime="2023-02-01T15:15:01+08:00">2023-02-01</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>之前从没遇见过,element的输入框用不了了。</p>
<ul>
<li><strong>版本说明</strong></li>
</ul>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">"vue"</span><span class="punctuation">:</span> <span class="string">"^3.2.45"</span><span class="punctuation">,</span></span><br><span class="line"><span class="attr">"element-plus"</span><span class="punctuation">:</span> <span class="string">"2.2.28"</span></span><br></pre></td></tr></table></figure>
<p>错误代码:</p>
<figure class="highlight js"><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><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <span class="language-xml"><span class="tag"><<span class="name">el-form</span> <span class="attr">ref</span>=<span class="string">"ruleFormRef"</span> <span class="attr">:model</span>=<span class="string">"ruleForm"</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-form-item</span> <span class="attr">v-model</span>=<span class="string">"ruleForm.tel"</span> <span class="attr">label</span>=<span class="string">"tel"</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-input</span> /></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"></<span class="name">el-form-item</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-form-item</span> <span class="attr">v-model</span>=<span class="string">"ruleForm.psw"</span> <span class="attr">label</span>=<span class="string">"password"</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-input</span> /></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"></<span class="name">el-form-item</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"></<span class="name">el-form</span>></span></span></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><span class="language-xml"><span class="tag"><<span class="name">script</span> <span class="attr">lang</span>=<span class="string">"ts"</span> <span class="attr">setup</span>></span><span class="language-javascript"></span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"><span class="keyword">import</span> { reactive } <span class="keyword">from</span> <span class="string">'vue'</span></span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"><span class="keyword">const</span> ruleForm = <span class="title function_">reactive</span>({</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"> <span class="attr">tel</span>: <span class="string">'133'</span>,</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"> <span class="attr">psw</span>: <span class="string">''</span>,</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml">})</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"></span><span class="tag"></<span class="name">script</span>></span></span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<ul>
<li><h1 id="A1-强制刷新"><a href="#A1-强制刷新" class="headerlink" title="A1:强制刷新"></a><strong>A1:强制刷新</strong></h1></li>
</ul>
<p>也是网上最主流的解决方法:在input组件中加一个强制刷新<code>@input="$forceUpdate()"</code></p>
<p>原理是:其实已经输入成功,只是视图层还没刷新。</p>
<p>我试了一下不行,于是在浏览器中打印了表单,发现还是js部分设置的原始ruleform</p>
<p></p>
<p>说明不是视图层没有刷新的问题</p>
<ul>
<li><h1 id="A2-没有设置v-model"><a href="#A2-没有设置v-model" class="headerlink" title="A2:没有设置v-model"></a><strong>A2:没有设置v-model</strong></h1></li>
</ul>
<p>网上说是没有设置v-modle 检查了一下都设置了呀</p>
<ul>
<li><h1 id="A3-v-model设置位置错误"><a href="#A3-v-model设置位置错误" class="headerlink" title="A3:v-model设置位置错误"></a><strong>A3:v-model设置位置错误</strong></h1></li>
</ul>
<p>是从这篇文章里找到的</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_45883730/article/details/108779686">https://blog.csdn.net/weixin_45883730/article/details/108779686</a></p>
<p></p>
<p>作者顺嘴提了一句,v-modle不要设置错了位置,检查一下竟是我本人。。感恩的心。。</p>
<p>ps.这篇也是网上解决该问题方案比较全的文章,推荐阅读</p>
<p>最后附正确代码</p>
<figure class="highlight js"><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><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <span class="language-xml"><span class="tag"><<span class="name">el-form</span> <span class="attr">ref</span>=<span class="string">"ruleFormRef"</span> <span class="attr">:model</span>=<span class="string">"ruleForm"</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-form-item</span> <span class="attr">label</span>=<span class="string">"tel"</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-input</span> <span class="attr">v-model</span>=<span class="string">"ruleForm.tel"</span> /></span>//改了这里</span></span><br><span class="line"><span class="language-xml"> <span class="tag"></<span class="name">el-form-item</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-form-item</span> <span class="attr">label</span>=<span class="string">"password"</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"><<span class="name">el-input</span> <span class="attr">v-model</span>=<span class="string">"ruleForm.psw"</span> /></span>//改了这里</span></span><br><span class="line"><span class="language-xml"> <span class="tag"></<span class="name">el-form-item</span>></span></span></span><br><span class="line"><span class="language-xml"> <span class="tag"></<span class="name">el-form</span>></span></span></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><span class="language-xml"><span class="tag"><<span class="name">script</span> <span class="attr">lang</span>=<span class="string">"ts"</span> <span class="attr">setup</span>></span><span class="language-javascript"></span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"><span class="keyword">import</span> { reactive } <span class="keyword">from</span> <span class="string">'vue'</span></span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"><span class="keyword">const</span> ruleForm = <span class="title function_">reactive</span>({</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"> <span class="attr">tel</span>: <span class="string">'133'</span>,</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"> <span class="attr">psw</span>: <span class="string">''</span>,</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml">})</span></span></span><br><span class="line"><span class="language-javascript"><span class="language-xml"></span><span class="tag"></<span class="name">script</span>></span></span></span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2023/01/28/post%E5%AE%9E%E7%8E%B0%E6%96%87%E4%BB%B6%E4%BC%A0%E8%BE%93/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/01/28/post%E5%AE%9E%E7%8E%B0%E6%96%87%E4%BB%B6%E4%BC%A0%E8%BE%93/" class="post-title-link" itemprop="url">post实现文件传输</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2023-01-28 15:08:30 / Modified: 18:08:58" itemprop="dateCreated datePublished" datetime="2023-01-28T15:08:30+08:00">2023-01-28</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>版本说明</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">% node -v</span><br><span class="line">v18.13.0</span><br></pre></td></tr></table></figure>
<h1 id="前端"><a href="#前端" class="headerlink" title="前端"></a>前端</h1><ul>
<li><h2 id="版本说明"><a href="#版本说明" class="headerlink" title="版本说明"></a><strong>版本说明</strong></h2></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">% npm axios -v</span><br><span class="line">8.19.3</span><br></pre></td></tr></table></figure>
<ul>
<li><h2 id="基本思路"><a href="#基本思路" class="headerlink" title="基本思路"></a><strong>基本思路</strong></h2></li>
</ul>
<p>生成buffer、获取文件名</p>
<p>将buffer对象和文件名发送至后端</p>
<ul>
<li><h2 id="附代码"><a href="#附代码" class="headerlink" title="附代码"></a><strong>附代码</strong></h2></li>
</ul>
<figure class="highlight js"><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="keyword">const</span> axios = <span class="built_in">require</span>(<span class="string">'axios'</span>)</span><br><span class="line"><span class="keyword">const</span> fs = <span class="built_in">require</span>(<span class="string">'fs'</span>)<span class="comment">//node的file system,核心模块无需下载</span></span><br><span class="line"><span class="keyword">const</span> path = <span class="built_in">require</span>(<span class="string">'path'</span>);<span class="comment">//核心模块无需下载</span></span><br><span class="line"><span class="keyword">const</span> file_name = path.<span class="title function_">basename</span>(<span class="string">'../pic/test.jpg'</span>);<span class="comment">//获取文件名,替换成自己的路径</span></span><br><span class="line"><span class="keyword">let</span> bitmap = fs.<span class="title function_">readFileSync</span>(<span class="string">'../pic/test.jpg'</span>);<span class="comment">//获取buffer,替换成自己的路径</span></span><br><span class="line"></span><br><span class="line">axios.<span class="title function_">post</span>(<span class="string">'http://localhost:8080/file'</span>, {</span><br><span class="line"> <span class="string">'file_name'</span>: file_name,</span><br><span class="line"> <span class="string">'bitmap'</span>: bitmap</span><br><span class="line">})</span><br><span class="line"> .<span class="title function_">then</span>(<span class="keyword">function</span> (<span class="params">response</span>) {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(response);</span><br><span class="line"> })</span><br><span class="line"> .<span class="title function_">catch</span>(<span class="keyword">function</span> (<span class="params">error</span>) {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(error);</span><br><span class="line"> });</span><br></pre></td></tr></table></figure>
<h1 id="后端"><a href="#后端" class="headerlink" title="后端"></a>后端</h1><ul>
<li><h2 id="版本说明-1"><a href="#版本说明-1" class="headerlink" title="版本说明"></a><strong>版本说明</strong></h2></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">% express --version</span><br><span class="line">4.16.1</span><br></pre></td></tr></table></figure>
<ul>
<li><h2 id="Q1:取不到前端请求的参数-gt-A:body-parser的使用"><a href="#Q1:取不到前端请求的参数-gt-A:body-parser的使用" class="headerlink" title="Q1:取不到前端请求的参数->A:body-parser的使用"></a><strong>Q1</strong>:<strong>取不到前端请求的参数->A:body-parser的使用</strong></h2></li>
</ul>
<p>首次在后端console.log(req),找不到前端发送过来的参数。</p>
<p>查看<a target="_blank" rel="noopener" href="https://expressjs.com/en/4x/api.html">express文档</a>后发现取到post方法的参数需要使用中间件。</p>
<p>express内置了express.json([options])(仅支持v4.16.0 以上),用来解析json格式的请求。同时该中间件是基于node提供的body-parser中间件,所以最后选择使用<a target="_blank" rel="noopener" href="https://github.com/expressjs/body-parser">body-parser</a>。</p>
<p>安装</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ npm install body-parser</span><br></pre></td></tr></table></figure>
<p>引入</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> bodyParser = <span class="built_in">require</span>(<span class="string">'body-parser'</span>)</span><br></pre></td></tr></table></figure>
<p>这个模块一共提供了四个解析器</p>
<ul>
<li>JSON body parser</li>
<li>Raw body parser</li>
<li>Text body parser</li>
<li>URL-encoded form body parser</li>
</ul>
<p>猜测这里只需要用到json的解析器</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> jsonParser = bodyParser.<span class="title function_">json</span>({})</span><br><span class="line">app.<span class="title function_">use</span>(jsonParser)</span><br></pre></td></tr></table></figure>
<p>哦豁报错了,说req太大了</p>
<p><code>PayloadTooLargeError: request entity too large</code></p>
<p>于是修改了一下前端,post了几个字符串过来,哎你猜怎么着,后端取到啦</p>
<p>看来取参应该是没问题了,传不过来是文件太大的问题</p>
<ul>
<li><h2 id="Q2-PayloadTooLargeError-request-entity-too-large-gt-A:提高limit"><a href="#Q2-PayloadTooLargeError-request-entity-too-large-gt-A:提高limit" class="headerlink" title="Q2:PayloadTooLargeError: request entity too large->A:提高limit"></a><strong>Q2:<code>PayloadTooLargeError: request entity too large</code>->A:提高limit</strong></h2></li>
</ul>
<p>关于传输大小的问题,body-parser的文档里有提到,如果有需要在body-parser.json({option})里修改选项</p>
<p>原文:</p>
<blockquote>
<h5 id="limit"><a href="#limit" class="headerlink" title="limit"></a>limit</h5><p>Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the <a target="_blank" rel="noopener" href="https://www.npmjs.com/package/bytes">bytes</a> library for parsing. Defaults to <code>'100kb'</code>.</p>
</blockquote>
<p>更改一下</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> jsonParser = bodyParser.<span class="title function_">json</span>({</span><br><span class="line"> <span class="attr">limit</span>: <span class="string">'50mb'</span></span><br><span class="line">})</span><br></pre></td></tr></table></figure>
<p>后端取到前端发来的bitmap啦</p>
<p>接着用fs的writeFile方法写入文件,又出现了新的报错</p>
<p><code>TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Array</code></p>
<ul>
<li><h2 id="Q3-fs-writeFile-只接收字符串或buffer对象-gt-A-把数组转换为buffer对象"><a href="#Q3-fs-writeFile-只接收字符串或buffer对象-gt-A-把数组转换为buffer对象" class="headerlink" title="Q3:fs.writeFile()只接收字符串或buffer对象->A:把数组转换为buffer对象"></a><strong>Q3:fs.writeFile()只接收字符串或buffer对象->A:把数组转换为buffer对象</strong></h2><p>先贴一下错误代码</p>
</li>
</ul>
<figure class="highlight js"><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></pre></td><td class="code"><pre><span class="line"><span class="comment">//我是错误代码</span></span><br><span class="line">app.<span class="title function_">post</span>(<span class="string">'/file'</span>, <span class="keyword">function</span> (<span class="params">req, res</span>) {</span><br><span class="line"> <span class="keyword">var</span> data = req.<span class="property">body</span>.<span class="property">bitmap</span>.<span class="property">data</span></span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(data)</span><br><span class="line"> fs.<span class="title function_">writeFile</span>(path, data, <span class="keyword">function</span> (<span class="params">err</span>) {</span><br><span class="line"> <span class="comment">//第一个参数是文件写入的路径</span></span><br><span class="line"> <span class="keyword">if</span> (!err) {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">"文件写入成功"</span>);</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(err)</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line">})</span><br></pre></td></tr></table></figure>
<p>其中<code>data</code>打出来长这样:明显是个数组。报错也说的很明白了,转成buffer对象就行</p>
<p><code>var data = Buffer.from(req.body.bitmap.data)</code></p>
<p>指定路径收到了前端发来的文件,大成功!</p>
<ul>
<li><h2 id="附全部代码"><a href="#附全部代码" class="headerlink" title="附全部代码"></a><strong>附全部代码</strong></h2></li>
</ul>
<figure class="highlight js"><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><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> express = <span class="built_in">require</span>(<span class="string">"express"</span>);</span><br><span class="line"><span class="keyword">const</span> app = <span class="title function_">express</span>();</span><br><span class="line"><span class="keyword">var</span> bodyParser = <span class="built_in">require</span>(<span class="string">'body-parser'</span>)<span class="comment">//中间件</span></span><br><span class="line"><span class="keyword">let</span> fs = <span class="built_in">require</span>(<span class="string">'fs'</span>)</span><br><span class="line"><span class="keyword">var</span> path = <span class="string">"../pic"</span>;<span class="comment">//要写入到哪里去,修改成自己的路径</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> jsonParser = bodyParser.<span class="title function_">json</span>({</span><br><span class="line"> <span class="attr">limit</span>: <span class="string">'50mb'</span></span><br><span class="line">})</span><br><span class="line">app.<span class="title function_">use</span>(jsonParser)</span><br><span class="line"></span><br><span class="line">app.<span class="title function_">post</span>(<span class="string">'/file'</span>, <span class="keyword">function</span> (<span class="params">req, res</span>) {</span><br><span class="line"> <span class="keyword">var</span> data = <span class="title class_">Buffer</span>.<span class="title function_">from</span>(req.<span class="property">body</span>.<span class="property">bitmap</span>.<span class="property">data</span>)</span><br><span class="line"> fs.<span class="title function_">writeFile</span>(path + <span class="string">'/'</span> + req.<span class="property">body</span>.<span class="property">file_name</span>, data, <span class="keyword">function</span> (<span class="params">err</span>) {</span><br><span class="line"> <span class="keyword">if</span> (!err) {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">"文件写入成功"</span>);</span><br><span class="line"> res.<span class="title function_">send</span>({ <span class="string">'msg'</span>: <span class="string">"写入成功"</span>, <span class="string">'code'</span>: <span class="number">1</span>, <span class="string">'path'</span>: path + <span class="string">'/'</span> + req.<span class="property">body</span>.<span class="property">file_name</span>, data })</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(err)</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line">})</span><br><span class="line">app.<span class="title function_">listen</span>(<span class="number">8080</span>, <span class="function">() =></span> {</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">"server start"</span>)</span><br><span class="line">})</span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2023/01/06/%E5%9F%BA%E4%BA%8Eexpress%E6%A1%86%E6%9E%B6%E7%9A%84node%E5%90%8E%E5%8F%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/01/06/%E5%9F%BA%E4%BA%8Eexpress%E6%A1%86%E6%9E%B6%E7%9A%84node%E5%90%8E%E5%8F%B0/" class="post-title-link" itemprop="url">基于express框架的node后台</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2023-01-06 23:32:54" itemprop="dateCreated datePublished" datetime="2023-01-06T23:32:54+08:00">2023-01-06</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2023-01-07 00:02:39" itemprop="dateModified" datetime="2023-01-07T00:02:39+08:00">2023-01-07</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>新建一个文件夹,进入该文件夹中,运行</p>
<p>文件夹命名:英文、不能有空格</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm init -y//生成package.json</span><br><span class="line">npm install//生成package-lock.json</span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2023/01/05/mysql-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/01/05/mysql-note/" class="post-title-link" itemprop="url">mysql常用指令备忘</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2023-01-05 20:54:02 / Modified: 21:54:25" itemprop="dateCreated datePublished" datetime="2023-01-05T20:54:02+08:00">2023-01-05</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<ul>
<li>登陆</li>
</ul>
<p><code>mysql -u root -p;</code></p>
<p>密码gymA20000925</p>
<ul>
<li>查看数据库</li>
</ul>
<p><code>show databases;</code></p>
<ul>
<li><p>新建数据库</p>
<p><code>create database 数据库名;</code></p>
<p>如新建名字为node_project的数据库</p>
<p><code>create database node_project;</code></p>
</li>
<li><p>新建表</p>
<p><code>use database_name</code></p>
<p><code>create table table_name(字段名 字段类型(长度),字段名 字段类型(长度)...);</code></p>
</li>
</ul>
<p>如在node_project的数据库下新建一个含name和password的表</p>
<figure class="highlight plaintext"><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">use database node_project</span><br><span class="line"></span><br><span class="line">create table users</span><br><span class="line"></span><br><span class="line"> -> (</span><br><span class="line"></span><br><span class="line"> -> name varchar(32),</span><br><span class="line"></span><br><span class="line"> -> password varchar(64)</span><br><span class="line"></span><br><span class="line"> -> );</span><br></pre></td></tr></table></figure>
<ul>
<li>删除数据库</li>
</ul>
<p><code>drop database 数据库名;</code></p>
<p>提醒:删除操作不可撤回,数据库中的表和数据都会被删除,请勿轻易执行</p>
<ul>
<li><p>通过脚本执行sql操作</p>
<p>新建sql脚本文件,例如init.sql,在该文件的目录下输入</p>
<p><code>mysql -uroot -p密码<init.sql</code></p>
</li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2022/10/07/%E8%80%83%E7%A0%94%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84802/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/10/07/%E8%80%83%E7%A0%94%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84802/" class="post-title-link" itemprop="url">考研数据结构802</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-10-07 20:19:55" itemprop="dateCreated datePublished" datetime="2022-10-07T20:19:55+08:00">2022-10-07</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2023-02-02 18:45:42" itemprop="dateModified" datetime="2023-02-02T18:45:42+08:00">2023-02-02</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>其实数据结构这门课理解的门槛很低,一些算法是小学生都可以理解的,但是难就难在知识点太多,学了后面就忘了前面,有点小文科的意思。</p>
<p>教材嘛,一是为了严谨所以太学术化书面化,有理解难度;二是知识面太全,很多地方并非考试重点;三是本f人最不能接受的:全是大段文字,文字间的逻辑关系不方便get到。</p>
<p>综上,只适合第一轮学习的时候看,并不方便二轮复习再来翻阅。故自行整理笔记方便复习。</p>
<p>本笔记尽可能采用表格表示各种概念算法等之间的关系,更加直观。适合辅助教材进行学习、理解背诵、做题速查。</p>
<h1 id="第四章-树"><a href="#第四章-树" class="headerlink" title="第四章 树"></a>第四章 树</h1><div class="pdf-container" data-target="/pdf/tree.pdf" data-height="1200px"></div>
<h1 id="第五章-图"><a href="#第五章-图" class="headerlink" title="第五章 图"></a>第五章 图</h1><div class="pdf-container" data-target="/pdf/graph.pdf" data-height="1200px"></div>
<h1 id="第六章-查找"><a href="#第六章-查找" class="headerlink" title="第六章 查找"></a>第六章 查找</h1><div class="pdf-container" data-target="/pdf/sereach.pdf" data-height="1200px"></div>
<h1 id="第七章-排序"><a href="#第七章-排序" class="headerlink" title="第七章 排序"></a>第七章 排序</h1><div class="pdf-container" data-target="/pdf/sort.pdf" data-height="1200px"></div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2022/05/01/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="meng-er">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="menger's blog">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | menger's blog">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/05/01/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" class="post-title-link" itemprop="url">操作系统</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-05-01 16:21:42" itemprop="dateCreated datePublished" datetime="2022-05-01T16:21:42+08:00">2022-05-01</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2023-02-01 16:29:06" itemprop="dateModified" datetime="2023-02-01T16:29:06+08:00">2023-02-01</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>期末复习用</p>
<div class="pdf-container" data-target="/pdf/os.pdf" data-height="1200px"></div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
©
<span itemprop="copyrightYear">2023</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">meng-er</span>
</div>
<div class="powered-by">Powered by <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a>
</div>
</div>
</footer>
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<div class="sidebar-dimmer"></div>
<div class="back-to-top" role="button" aria-label="Back to top">
<i class="fa fa-arrow-up fa-lg"></i>
<span>0%</span>
</div>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>
<script class="next-config" data-name="pdf" type="application/json">{"object_url":{"url":"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.2.8/pdfobject.min.js","integrity":"sha256-tu9j5pBilBQrWSDePOOajCUdz6hWsid/lBNzK4KgEPM="},"url":"/lib/pdf/web/viewer.html"}</script>
<script src="/js/third-party/tags/pdf.js"></script>
</body>
</html>