-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1312 lines (713 loc) · 90.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
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 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 6.0.0">
<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://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/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":"Gemini","version":"8.7.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"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"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>
<meta name="description" content="Never stop learning">
<meta property="og:type" content="website">
<meta property="og:title" content="Xiaolong's Blog">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="Xiaolong's Blog">
<meta property="og:description" content="Never stop learning">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="Xiaolong">
<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>Xiaolong'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">
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="Toggle navigation bar" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<h1 class="site-title">Xiaolong's Blog</h1>
<i class="logo-line"></i>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
<i class="fa fa-search fa-fw fa-lg"></i>
</div>
</div>
</div>
<nav class="site-nav">
<ul class="main-menu menu">
<li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a></li>
<li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a></li>
<li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a></li>
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>Search
</a>
</li>
</ul>
</nav>
<div class="search-pop-overlay">
<div class="popup search-popup"><div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocapitalize="off" maxlength="80"
placeholder="Searching..." spellcheck="false"
type="search" class="search-input">
</div>
<span class="popup-btn-close" role="button">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div class="search-result-container no-result">
<div class="search-result-icon">
<i class="fa fa-spinner fa-pulse fa-5x"></i>
</div>
</div>
</div>
</div>
</div>
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<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-overview">
<div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" alt="Xiaolong"
src="/images/lion.jpg">
<p class="site-author-name" itemprop="name">Xiaolong</p>
<div class="site-description" itemprop="description">Never stop learning</div>
</div>
<div class="site-state-wrap site-overview-item animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">45</span>
<span class="site-state-item-name">posts</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/">
<span class="site-state-item-count">17</span>
<span class="site-state-item-name">tags</span></a>
</div>
</nav>
</div>
<div class="links-of-author site-overview-item animated">
<span class="links-of-author-item">
<a href="https://github.com/drwna" title="GitHub → https://github.com/drwna" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
</span>
</div>
</div>
</div>
</div>
<div class="back-to-top animated" role="button" aria-label="Back to top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
</div>
</aside>
<div class="sidebar-dimmer"></div>
</header>
<div class="reading-progress-bar"></div>
<a href="https://github.com/Drwna" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<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/03/07/00/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/03/07/00/" class="post-title-link" itemprop="url">vim + Vscode / WebStorm</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-03-07 00:00:00" itemprop="dateCreated datePublished" datetime="2023-03-07T00:00:00+08:00">2023-03-07</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Vim-VScode-WebStorm"><a href="#Vim-VScode-WebStorm" class="headerlink" title="Vim + VScode / WebStorm"></a>Vim + VScode / WebStorm</h1><p>使用 vim 快捷键的好处:</p>
<ol>
<li>提高效率。</li>
<li>统一 WebStorm(JetBrains 系列软件) 和 VScode 的快捷键操作。</li>
</ol>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/03/07/00/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</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/26/00/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/01/26/00/" class="post-title-link" itemprop="url">Uniapp 开发记录</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-26 00:00:00" itemprop="dateCreated datePublished" datetime="2023-01-26T00:00:00+08:00">2023-01-26</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Uniapp-开发记录"><a href="#Uniapp-开发记录" class="headerlink" title="Uniapp 开发记录"></a><strong>Uniapp</strong> 开发记录</h1><h2 id="使用-Vue3-的-setup-语法糖"><a href="#使用-Vue3-的-setup-语法糖" class="headerlink" title="使用 Vue3 的 setup 语法糖"></a>使用 Vue3 的 setup 语法糖</h2><h2 id="配置跨域代理"><a href="#配置跨域代理" class="headerlink" title="配置跨域代理"></a>配置跨域代理</h2>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2023/01/26/00/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</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/12/01/00/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/12/01/00/" class="post-title-link" itemprop="url">Canvas</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-12-01 00:00:00" itemprop="dateCreated datePublished" datetime="2022-12-01T00:00:00+08:00">2022-12-01</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="canvas"><a href="#canvas" class="headerlink" title="canvas"></a>canvas</h1><h2 id="创建高清的-canvas"><a href="#创建高清的-canvas" class="headerlink" title="创建高清的 canvas"></a>创建高清的 canvas</h2><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></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> createHDCanvas = (w, h) = >{</span><br><span class="line"> <span class="keyword">const</span> canvas = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">"canvas"</span>);</span><br><span class="line"> <span class="keyword">const</span> ratio = <span class="variable language_">window</span>.<span class="property">devicePixelRatio</span> || <span class="number">1</span>;</span><br><span class="line"> canvas.<span class="property">width</span> = w * ratio; <span class="comment">// 实际渲染像素</span></span><br><span class="line"> canvas.<span class="property">height</span> = h * ratio; <span class="comment">// 实际渲染像素</span></span><br><span class="line"> canvas.<span class="property">style</span>.<span class="property">width</span> = <span class="string">`<span class="subst">${w}</span>px`</span>; <span class="comment">// 控制显示大小</span></span><br><span class="line"> canvas.<span class="property">style</span>.<span class="property">height</span> = <span class="string">`<span class="subst">${h}</span>px`</span>; <span class="comment">// 控制显示大小</span></span><br><span class="line"> <span class="keyword">const</span> ctx = canvas.<span class="title function_">getContext</span>(<span class="string">"2d"</span>);</span><br><span class="line"> ctx.<span class="title function_">scale</span>(ratio, ratio);</span><br><span class="line"> <span class="comment">// canvas 绘制</span></span><br><span class="line"> <span class="keyword">return</span> canvas;</span><br><span class="line">};</span><br></pre></td></tr></table></figure>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/12/01/00/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</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/03/28/47/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/03/28/47/" class="post-title-link" itemprop="url">code</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-03-28 22:03:47" itemprop="dateCreated datePublished" datetime="2022-03-28T22:03:47+08:00">2022-03-28</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>常用代码</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2022/03/28/47/#more" rel="contents">
Read more »
</a>
</div>
<!--/noindex-->
</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/03/04/45/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/03/04/45/" class="post-title-link" itemprop="url">test</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-03-04 18:11:45" itemprop="dateCreated datePublished" datetime="2022-03-04T18:11:45+08:00">2022-03-04</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="test"><a href="#test" class="headerlink" title="test"></a>test</h1>
</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/02/12/20/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/02/12/20/" class="post-title-link" itemprop="url">wheel ui</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-02-12 23:57:20" itemprop="dateCreated datePublished" datetime="2022-02-12T23:57:20+08:00">2022-02-12</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="初始化-vue-router"><a href="#初始化-vue-router" class="headerlink" title="初始化 vue-router"></a>初始化 vue-router</h2><p>新建 history 对象</p>
<p>新建 router 对象</p>
<p>app.use(router)</p>
<figure class="highlight ts"><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="keyword">const</span> history = <span class="title function_">createWebHashHistory</span>();</span><br><span class="line"><span class="keyword">const</span> router = <span class="title function_">createRouter</span>({</span><br><span class="line"> <span class="attr">history</span>: history,</span><br><span class="line"> <span class="attr">routes</span>: [{ <span class="attr">path</span>: <span class="string">"/"</span>, <span class="attr">component</span>: <span class="title class_">HelloWorld</span> }],</span><br><span class="line">});</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> app = <span class="title function_">createApp</span>(<span class="title class_">App</span>);</span><br><span class="line">app.<span class="title function_">use</span>(router);</span><br><span class="line">app.<span class="title function_">mount</span>(<span class="string">"#app"</span>);</span><br></pre></td></tr></table></figure>
<!--mor
添加 `<router-view>` `<router-link>`
<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><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"><template></span><br><span class="line"> <div></span><br><span class="line"> 导航栏 |</span><br><span class="line"> <router-link to="/"> frank </router-link> |</span><br><span class="line"> <router-link to="/xxx"> frank2</router-link></span><br><span class="line"> </div></span><br><span class="line"> <hr /></span><br><span class="line"> <router-view /></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script></span><br><span class="line">export default {</span><br><span class="line"> name: "App",</span><br><span class="line">};</span><br><span class="line"></script></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<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><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></pre></td><td class="code"><pre><span class="line">yarn global add create-vite-app</span><br><span class="line">cva wheel-ui</span><br><span class="line">// 等价于</span><br><span class="line">npm init vite-app <</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">cd wheel-ui</span><br><span class="line">yarn install</span><br><span class="line">yarn dev</span><br><span class="line"></span><br><span class="line">// 查看 vue-router 所有版本号</span><br><span class="line">npm info nue-router versions</span><br><span class="line"></span><br><span class="line">// 安装 vue-router</span><br><span class="line">yarn add vue-router</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">yarn add -D sass</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<blockquote>
<p>vite 文档给出的命令是</p>
<p>npm init vite-app 项目名</p>
<p>yarn create vite-app 项目名</p>
<p>等价于</p>
<p>yarn global creat-vite-app</p>
<p>cva 项目名</p>
<p>也等价于</p>
<p>npx create-vite-app 项目名</p>
<p>即 npx 会帮你全局安装用到的包</p>
</blockquote>
<h2 id="provide-inject"><a href="#provide-inject" class="headerlink" title="provide inject"></a>provide inject</h2><p>需求:点击子组件 A ,隐藏子组件 B 某一内容。</p>
<p>App.vue</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></pre></td><td class="code"><pre><span class="line"><script lang="ts"></span><br><span class="line">import { provide, ref } from "vue";</span><br><span class="line">export default {</span><br><span class="line"> name: "App",</span><br><span class="line"> setup() {</span><br><span class="line"> const asideVisible = ref(false); // set</span><br><span class="line"> provide("xxx", asideVisible);</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<p>子组件 A</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><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"><!-- Topnav.vue --></span><br><span class="line"><template></span><br><span class="line"> <div class="topnav"></span><br><span class="line"> <div class="logo" @click="toggleAside">LOGO</div></span><br><span class="line"> </div></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script lang="ts"></span><br><span class="line">import Vue, { inject, Ref } from "vue";</span><br><span class="line">export default {</span><br><span class="line"> setup() {</span><br><span class="line"> const asideVisible = inject<Ref<boolean>>("xxx");</span><br><span class="line"> const toggleAside = () => {</span><br><span class="line"> asideVisible.value = !asideVisible.value;</span><br><span class="line"> };</span><br><span class="line"> return { toggleAside };</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<p>子组件 B</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><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></pre></td><td class="code"><pre><span class="line"><!-- Doc.vue --></span><br><span class="line"><template></span><br><span class="line"> <div></span><br><span class="line"> <Topnav /></span><br><span class="line"> <div class="content"></span><br><span class="line"> <aside v-if="asideVisible"></span><br><span class="line"> ...</span><br><span class="line"> </aside></span><br><span class="line"> </div></span><br><span class="line"> </div></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script lang="ts"></span><br><span class="line">import Topnav from "../components/Topnav.vue";</span><br><span class="line">import { inject, Ref } from "vue";</span><br><span class="line">export default {</span><br><span class="line"> components: { Topnav },</span><br><span class="line"> setup() {</span><br><span class="line"> const asideVisible = inject<Ref<boolean>>("xxx");</span><br><span class="line"> return { asideVisible };</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<h2 id="TS-引入-vue文件"><a href="#TS-引入-vue文件" class="headerlink" title="TS 引入 .vue文件"></a>TS 引入 .vue文件</h2><p><strong>找不到模块“./App.vue”或其相应的类型声明。ts(2307)</strong></p>
<p>src 目录下创建以 .d.ts 为结尾的文件</p>
<figure class="highlight ts"><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="comment">// shims-vue.d.ts</span></span><br><span class="line"><span class="keyword">declare</span> <span class="variable language_">module</span> <span class="string">'*.vue'</span> {</span><br><span class="line"> <span class="keyword">import</span> { <span class="title class_">ComponentOptions</span> } <span class="keyword">from</span> <span class="string">"vue"</span>;</span><br><span class="line"> <span class="keyword">const</span> <span class="attr">componentOptions</span>:<span class="title class_">ComponentOptions</span> </span><br><span class="line"> <span class="keyword">export</span> <span class="keyword">default</span> componentOptions</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<h2 id="error-Command-failed-with-exit-code-1"><a href="#error-Command-failed-with-exit-code-1" class="headerlink" title="error Command failed with exit code 1."></a>error Command failed with exit code 1.</h2><center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-08_15-42-14.png" alt="Snipaste_2022-02-08_15-42-14" width="800px"></center>
<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-08_15-42-14.png" alt="Snipaste_2022-02-08_15-42-14" width="800px"></center>
<p>解决:</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></pre></td><td class="code"><pre><span class="line">rm -rf node_modules/</span><br><span class="line">yarn cache clean</span><br><span class="line">yarn install</span><br></pre></td></tr></table></figure>
<h2 id="父子组件通信"><a href="#父子组件通信" class="headerlink" title="父子组件通信"></a>父子组件通信</h2><p>父组件</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><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <Switch :value="y" @input="y = $event" /></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script lang="ts"></span><br><span class="line">import Switch from "../lib/Switch.vue";</span><br><span class="line">import { ref } from "vue";</span><br><span class="line">export default {</span><br><span class="line"> components: { Switch },</span><br><span class="line"> setup() {</span><br><span class="line"> const y = ref(false);</span><br><span class="line"> return { y };</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<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"><template> <button @click="toggle" :class="{ checked: value }"> <span></span> </button></template><script lang="ts">import { ref } from "vue";export default { props: { value: Boolean, }, setup(props, context) { const toggle = () => { // 核心 context.emit("input", !props.value); }; return { toggle }; },};</script></span><br></pre></td></tr></table></figure>
<p>或者使用 <strong>v-model</strong></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"><Switch v-model:value="y" /></span><br></pre></td></tr></table></figure>
<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">context.emit("update:value", !props.value);</span><br></pre></td></tr></table></figure>
<h2 id="属性绑定"><a href="#属性绑定" class="headerlink" title="属性绑定"></a>属性绑定</h2><p>默认所有属性都绑定到根元素。</p>
<p>使用 <code>inheritAttrs: false</code> 可以取消默认绑定。</p>
<p>使用 <code>$attrs</code> 或者 <code>context.attrs</code> 获取所有属性。</p>
<p>使用 <code>v-bind=“$attrs”</code> 批量绑定属性。</p>
<p>使用 <code>cons {size, ...rest} = context.attrs</code> 将属性放分开。</p>
<p><strong>父组件</strong></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><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></pre></td><td class="code"><pre><span class="line">// ButtonDemo.vue</span><br><span class="line"><template></span><br><span class="line"> <div>Button 示例</div></span><br><span class="line"> <h1>示例1</h1></span><br><span class="line"> <div></span><br><span class="line"> <Button @click="onClick" </span><br><span class="line"> @mouseover="onClick" </span><br><span class="line"> size="small">你好</Button></span><br><span class="line"> </div></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script lang="ts"></span><br><span class="line">import Button from "../lib/Button.vue";</span><br><span class="line">export default {</span><br><span class="line"> components: { Button },</span><br><span class="line"> setup() {</span><br><span class="line"> const onClick = () => {</span><br><span class="line"> alert("hello");</span><br><span class="line"> };</span><br><span class="line"> return { onClick };</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<p><strong>子组件</strong></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><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></pre></td><td class="code"><pre><span class="line">// Button.vue</span><br><span class="line"><template></span><br><span class="line"> // 将 size 属性绑定到根元素</span><br><span class="line"> <div :size="size"></span><br><span class="line"> // 将其余的属性绑定到目标元素</span><br><span class="line"> <button v-bind="rest"></span><br><span class="line"> <slot /></span><br><span class="line"> </button></span><br><span class="line"> </div></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script lang="ts"></span><br><span class="line">export default {</span><br><span class="line"> // 取消默认绑定到根元素</span><br><span class="line"> inheritAttrs: false,</span><br><span class="line"> setup(props, context) {</span><br><span class="line"> const { size, ...rest } = context.attrs;</span><br><span class="line"> return { size, rest };</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<h2 id="开发-UI-库的-CSS-注意事项"><a href="#开发-UI-库的-CSS-注意事项" class="headerlink" title="开发 UI 库的 CSS 注意事项"></a>开发 UI 库的 CSS 注意事项</h2><p><strong>不能使用 scoped</strong></p>
<p>因为 data-v-xxx 中的 xxx 不能保证每次运行都相同,必须输出稳定不变的 class 选择器,方便使用者覆盖。</p>
<p><strong>必须加前缀</strong></p>
<p>.button 不行,很容易被使用者覆盖,.wheel-button 行,不太容易被覆盖。</p>
<p>.theme-link 不行,很容易被使用者覆盖,.wheel-theme-link 行,不太容易被覆盖。</p>
<h2 id="插槽"><a href="#插槽" class="headerlink" title="插槽"></a>插槽</h2><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"><template> <div class="wheel-dialog"> <header> <slot name="title"/> <span @click="close"></span> </header> <main> <slot name="content"/> </main> </template></span><br></pre></td></tr></table></figure>
<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"><template> <div> <template v-slot:content> <div>你好</div> <div>hello</div> </template> <template v-slot:title> <strong>xxx</strong> </template> </div></template></span><br></pre></td></tr></table></figure>
<h2 id="Teleport"><a href="#Teleport" class="headerlink" title="Teleport"></a>Teleport</h2><p>将 xxx 传送到 body 下</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"><Teleport to="body"> xxx</Teleport></span><br></pre></td></tr></table></figure>
<h2 id="openDialog"><a href="#openDialog" class="headerlink" title="openDialog"></a>openDialog</h2><p>openDialog.js</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="title class_">Dialog</span> <span class="keyword">from</span> <span class="string">'./Dialog.vue'</span>;<span class="keyword">import</span> {createApp, h} <span class="keyword">from</span> <span class="string">'vue'</span>;<span class="keyword">export</span> <span class="keyword">const</span> <span class="title function_">openDialog</span> = (<span class="params">options</span>) => { <span class="keyword">const</span> {title, content, closeOnClickOverlay, ok, cancel} = options; <span class="keyword">const</span> div = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'div'</span>); <span class="variable language_">document</span>.<span class="property">body</span>.<span class="title function_">appendChild</span>(div); <span class="keyword">const</span> <span class="title function_">close</span> = (<span class="params"></span>) => { <span class="comment">//@ts-ignore app.unmount(div); div.remove(); }; const app = createApp({ render() { return h(Dialog, { visible: true, closeOnClickOverlay, 'onUpdate:visible': (newVisible) => {if (newVisible === false) close(); }, ok, cancel }, {title, content}); } }); app.mount(div);};</span></span><br></pre></td></tr></table></figure>
<p>vue 组件使用</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">const</span> <span class="title function_">showDialog</span> = (<span class="params"></span>) => { <span class="title function_">openDialog</span>({ <span class="attr">title</span>: <span class="string">'标题'</span>, <span class="attr">content</span>: <span class="string">'你好啊'</span>, <span class="attr">closeOnClickOverlay</span>: <span class="literal">false</span>, <span class="title function_">ok</span>(<span class="params"></span>) {<span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">'ok'</span>);}, <span class="title function_">cancel</span>(<span class="params"></span>) {<span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">'cancel'</span>);} }); };</span><br></pre></td></tr></table></figure>
<h2 id="检查子组件的类型"><a href="#检查子组件的类型" class="headerlink" title="检查子组件的类型"></a>检查子组件的类型</h2><p>获取插槽内容 <code>const defaults = context.slots.default()</code></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"><template> <div> Tabs 组件 </div> <component :is="defaults[0]"/> <component :is="defaults[1]"/></template><script lang="ts">import Tab from '../lib/Tab.vue';export default { setup(props, context) { // 调试 检查子组件是否为 Tab 组件 // console.log({...context.slots.default()[0]}); // console.log({...context.slots.default()[1]}); // const defaults = context.slots.default(); // console.log(defaults[0].type === Tab); const defaults = context.slots.default(); defaults.forEach(tag => { if (tag.type !== Tab) { throw new Error('Tabs 子标签必须是 Tab'); } }); return {defaults}; }};</script></span><br></pre></td></tr></table></figure>
<p>获取 el 的 width、left <code>const {width, height, left, top} = el.getBoundingClientRect()</code></p>
<h2 id="CSS-最小影响原则"><a href="#CSS-最小影响原则" class="headerlink" title="CSS 最小影响原则"></a>CSS 最小影响原则</h2><p>css 绝对不能影响库的使用者。</p>
<h2 id="markdown"><a href="#markdown" class="headerlink" title="markdown"></a>markdown</h2><p><code>yarn add --dev marked</code></p>
<p>新建 plugins/md.ts</p>
<figure class="highlight ts"><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><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// @ts-nocheck</span></span><br><span class="line"><span class="keyword">import</span> path <span class="keyword">from</span> <span class="string">'path'</span>;</span><br><span class="line"><span class="keyword">import</span> fs <span class="keyword">from</span> <span class="string">'fs'</span>;</span><br><span class="line"><span class="keyword">import</span> { marked } <span class="keyword">from</span> <span class="string">'marked'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">mdToJs</span> = str => {</span><br><span class="line"> <span class="keyword">const</span> content = <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(<span class="title function_">marked</span>(str));</span><br><span class="line"> <span class="keyword">return</span> <span class="string">`export default <span class="subst">${content}</span>`</span>;</span><br><span class="line">};</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">md</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">return</span> {</span><br><span class="line"> <span class="attr">configureServer</span>: [ <span class="comment">// 用于开发</span></span><br><span class="line"> <span class="keyword">async</span> ({app}) => {</span><br><span class="line"> app.<span class="title function_">use</span>(<span class="keyword">async</span> (ctx, next) => { <span class="comment">// koa</span></span><br><span class="line"> <span class="keyword">if</span> (ctx.<span class="property">path</span>.<span class="title function_">endsWith</span>(<span class="string">'.md'</span>)) {</span><br><span class="line"> ctx.<span class="property">type</span> = <span class="string">'js'</span>;</span><br><span class="line"> <span class="keyword">const</span> filePath = path.<span class="title function_">join</span>(process.<span class="title function_">cwd</span>(), ctx.<span class="property">path</span>);</span><br><span class="line"> ctx.<span class="property">body</span> = <span class="title function_">mdToJs</span>(fs.<span class="title function_">readFileSync</span>(filePath).<span class="title function_">toString</span>());</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="keyword">await</span> <span class="title function_">next</span>();</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"> },</span><br><span class="line"> ],</span><br><span class="line"> <span class="attr">transforms</span>: [{ <span class="comment">// 用于 rollup // 插件</span></span><br><span class="line"> <span class="attr">test</span>: <span class="function"><span class="params">context</span> =></span> context.<span class="property">path</span>.<span class="title function_">endsWith</span>(<span class="string">'.md'</span>),</span><br><span class="line"> <span class="attr">transform</span>: <span class="function">(<span class="params">{code}</span>) =></span> <span class="title function_">mdToJs</span>(code)</span><br><span class="line"> }]</span><br><span class="line"> };</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>新建 vite.config.ts</p>
<figure class="highlight ts"><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></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> {md} <span class="keyword">from</span> <span class="string">'./plugins/md'</span>;</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="attr">plugins</span>: [<span class="title function_">md</span>()]</span><br><span class="line">};</span><br></pre></td></tr></table></figure>
<p>使用</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"><template></span><br><span class="line"> <article class="markdown-body" v-html="md"></article></span><br><span class="line"></template></span><br><span class="line"><script lang="ts"></span><br><span class="line">// intro.md 为写好的 markdown文件</span><br><span class="line">import md from '../markdown/intro.md';</span><br><span class="line"> </span><br><span class="line">export default {</span><br><span class="line"> data() { return {md}; }</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<h2 id="消除重复-markdown"><a href="#消除重复-markdown" class="headerlink" title="消除重复 markdown"></a>消除重复 markdown</h2><p>使用动态引入 <code>import()</code> ==异步操作==</p>
<p>Markdown.vue</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><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><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <article class="markdown-body" v-html="content"></article></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script lang="ts"></span><br><span class="line">import {ref} from 'vue';</span><br><span class="line">export default {</span><br><span class="line"> props: {</span><br><span class="line"> path: {</span><br><span class="line"> type: String,</span><br><span class="line"> required: true</span><br><span class="line"> }</span><br><span class="line"> },</span><br><span class="line"> setup(props) {</span><br><span class="line"> // 核心</span><br><span class="line"> const content = ref<string>();</span><br><span class="line"> import(props.path).then(result => {</span><br><span class="line"> console.log(result.default);</span><br><span class="line"> // 动态引用 3s 后才会出现</span><br><span class="line"> setTimeout(() => {</span><br><span class="line"> content.value = result.default;</span><br><span class="line"> }, 3000);</span><br><span class="line"> });</span><br><span class="line"> return {content};</span><br><span class="line"> }</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure>
<p>使用</p>
<p>Intro.vue</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"><template> <Markdown path="../markdown/intro.md"/></template><script lang="ts">import Markdown from '../components/Markdown.vue';export default {components: {Markdown},};</script></span><br></pre></td></tr></table></figure>
<p>或者直接全局引入 Markdown 组件,就不需要每个组件单独引入了。</p>
<p>main.ts <code>app.component('Markdown', Markdown)</code></p>
<p><strong>进一步优化:</strong></p>
<p>直接在 router.js 里渲染,删除无用的 intro.vue</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> history = <span class="title function_">createWebHashHistory</span>();<span class="comment">// 核心const md = filename => h(Markdown, {path: `../markdown/${filename}.md`, key: filename});export const router = createRouter({ history: history, routes: [ {path: '/', component: Home}, { path: '/doc', component: Doc, children: [ {path: '', component: DocDemo}, // 核心 {path: 'intro', component: md('intro')}, {path: 'install', component: md('install')}, {path: 'get-started', component: md('get-started')}, // {path: 'switch', component: SwitchDemo}, ... ], }, ],});</span></span><br></pre></td></tr></table></figure>
<h2 id="展示源代码"><a href="#展示源代码" class="headerlink" title="展示源代码"></a>展示源代码</h2><p>配置 vite.config.ts</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> {md} <span class="keyword">from</span> <span class="string">'./plugins/md'</span>;<span class="keyword">import</span> * <span class="keyword">as</span> fs <span class="keyword">from</span> <span class="string">'fs'</span>;<span class="keyword">import</span> {baseParse} <span class="keyword">from</span> <span class="string">'@vue/compiler-core'</span>;<span class="keyword">export</span> <span class="keyword">default</span> { <span class="attr">plugins</span>: [<span class="title function_">md</span>()], <span class="attr">vueCustomBlockTransforms</span>: { <span class="attr">demo</span>: <span class="function">(<span class="params">options</span>) =></span> { <span class="keyword">const</span> {code, path} = options; <span class="keyword">const</span> file = fs.<span class="title function_">readFileSync</span>(path).<span class="title function_">toString</span>(); <span class="comment">//@ts-ignore const parsed = baseParse(file).children.find(n => n.tag === 'demo'); //@ts-ignore const title = parsed.children[0].content; const main = file.split(parsed.loc.source).join('').trim(); return `export default function (Component) { Component.__sourceCode = ${ JSON.stringify(main) } Component.__sourceCodeTitle = ${JSON.stringify(title)} }`.trim(); } }};</span></span><br></pre></td></tr></table></figure>
<p>SwitchDemo.vue</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"><template> <div> <div class="demo-code"> <!-- 用法 --> <pre>{{ Switch1Demo.__sourceCode }}</pre> </div> </div></template><script lang="ts">export default { components: {Switch2Demo, Switch1Demo,Switch,Button}, setup() { const bool = ref(false); return {bool, Switch1Demo, Switch2Demo}; }};</script></span><br></pre></td></tr></table></figure>
<p>Switch1Demo.vue 组件开头添加上 <code><demo>xxx</demo></code></p>
<h2 id="高亮源代码"><a href="#高亮源代码" class="headerlink" title="高亮源代码"></a>高亮源代码</h2><p>使用 prismjs</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><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">yarn add prismjs</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">导入</span><br><span class="line">import Prism from 'prismjs';</span><br><span class="line">import '../../node_modules/prismjs/themes/prism.min.css';</span><br><span class="line"></span><br><span class="line">...</span><br><span class="line">set(){</span><br><span class="line">return (Prism)</span><br><span class="line">}</span><br><span class="line">...</span><br><span class="line"></span><br><span class="line">使用</span><br><span class="line"><pre class="language-css" v-html="Prism.highlight(Switch1Demo.__sourceCode, Prism.languages.html, 'html')"/></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="Vue2-和-Vue3-的区别"><a href="#Vue2-和-Vue3-的区别" class="headerlink" title="Vue2 和 Vue3 的区别"></a>Vue2 和 Vue3 的区别</h2><ul>
<li>Vue3 的 template 支持==多个跟标签==,Vue2 不支持。</li>
<li>Vue3 有 <code>createApp()</code> ,而Vue2 的是 <code>new Vue()</code></li>
<li>Vue3 <code>createApp(组件)</code>,Vue2 <code>new Vue({template, render})</code></li>
</ul>
<p>v-model 代替以前的 <del>v-model</del>,<del>.sync</del>。</p>
<p>新增 context.emit 和 this.$emit 作用相同。</p>
<h2 id="部署上线注意事项"><a href="#部署上线注意事项" class="headerlink" title="部署上线注意事项"></a>部署上线注意事项</h2><p>配置 vite.config.ts</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">base: './',</span><br><span class="line">assetsDir: 'assets',</span><br></pre></td></tr></table></figure>
<h2 id="报错"><a href="#报错" class="headerlink" title="报错"></a>报错</h2><p>runtime-core.esm-bundler.js?5c40:38 [Vue warn]: Invalid VNode type: Symbol(Comment) (symbol) </p>
<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-15_20-47-46.png" alt="Snipaste_2022-02-15_20-47-46" width="800px"></center>
<p>解决:</p>
<p>vue.config.js</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></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> path = <span class="built_in">require</span>(<span class="string">`path`</span>);</span><br><span class="line"></span><br><span class="line"><span class="variable language_">module</span>.<span class="property">exports</span> = {</span><br><span class="line"> <span class="attr">configureWebpack</span>: {</span><br><span class="line"> <span class="attr">resolve</span>: {</span><br><span class="line"> <span class="attr">symlinks</span>: <span class="literal">false</span>,</span><br><span class="line"> <span class="attr">alias</span>: {</span><br><span class="line"> <span class="attr">vue</span>: path.<span class="title function_">resolve</span>(<span class="string">`./node_modules/vue`</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>
<p>rollup -c</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><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><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"whl-ui"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"version"</span><span class="punctuation">:</span> <span class="string">"0.0.2"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"files"</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line"> <span class="string">"dist/lib/*"</span></span><br><span class="line"> <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"main"</span><span class="punctuation">:</span> <span class="string">"dist/lib/whl.js"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"scripts"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"dev"</span><span class="punctuation">:</span> <span class="string">"vite"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"build"</span><span class="punctuation">:</span> <span class="string">"vite build"</span></span><br><span class="line"> <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"resolutions"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"node-sass"</span><span class="punctuation">:</span> <span class="string">"npm:sass@^1.26.11"</span></span><br><span class="line"> <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"dependencies"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"github-markdown-css"</span><span class="punctuation">:</span> <span class="string">"4.0.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"marked"</span><span class="punctuation">:</span> <span class="string">"4.0.12"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"prismjs"</span><span class="punctuation">:</span> <span class="string">"1.21.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"vue"</span><span class="punctuation">:</span> <span class="string">"3.0.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"vue-router"</span><span class="punctuation">:</span> <span class="string">"4.0.0-beta.3"</span></span><br><span class="line"> <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"devDependencies"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"@types/prismjs"</span><span class="punctuation">:</span> <span class="string">"^1.26.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"@vue/compiler-sfc"</span><span class="punctuation">:</span> <span class="string">"3.0.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-esbuild"</span><span class="punctuation">:</span> <span class="string">"2.5.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-scss"</span><span class="punctuation">:</span> <span class="string">"2.6.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-terser"</span><span class="punctuation">:</span> <span class="string">"7.0.2"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-vue"</span><span class="punctuation">:</span> <span class="string">"6.0.0-beta.10"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"sass"</span><span class="punctuation">:</span> <span class="string">"1.26.11"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"vite"</span><span class="punctuation">:</span> <span class="string">"1.0.0-rc.1"</span></span><br><span class="line"> <span class="punctuation">}</span></span><br><span class="line"><span class="punctuation">}</span></span><br></pre></td></tr></table></figure>
<p>yarn build</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><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><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"whl-ui"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"version"</span><span class="punctuation">:</span> <span class="string">"0.0.2"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"files"</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line"> <span class="string">"dist/lib/*"</span></span><br><span class="line"> <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"main"</span><span class="punctuation">:</span> <span class="string">"dist/lib/whl.js"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"scripts"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"dev"</span><span class="punctuation">:</span> <span class="string">"vite"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"build"</span><span class="punctuation">:</span> <span class="string">"vite build"</span></span><br><span class="line"> <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"resolutions"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"node-sass"</span><span class="punctuation">:</span> <span class="string">"npm:sass@^1.26.11"</span></span><br><span class="line"> <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"dependencies"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"github-markdown-css"</span><span class="punctuation">:</span> <span class="string">"4.0.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"marked"</span><span class="punctuation">:</span> <span class="string">"4.0.12"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"prismjs"</span><span class="punctuation">:</span> <span class="string">"1.21.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"vue"</span><span class="punctuation">:</span> <span class="string">"^3.0.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"vue-router"</span><span class="punctuation">:</span> <span class="string">"4.0.0-beta.3"</span></span><br><span class="line"> <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"devDependencies"</span><span class="punctuation">:</span> <span class="punctuation">{</span></span><br><span class="line"> <span class="attr">"@types/prismjs"</span><span class="punctuation">:</span> <span class="string">"^1.26.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"@vue/compiler-sfc"</span><span class="punctuation">:</span> <span class="string">"^3.0.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-esbuild"</span><span class="punctuation">:</span> <span class="string">"2.5.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-scss"</span><span class="punctuation">:</span> <span class="string">"2.6.0"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-terser"</span><span class="punctuation">:</span> <span class="string">"7.0.2"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"rollup-plugin-vue"</span><span class="punctuation">:</span> <span class="string">"6.0.0-beta.10"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"sass"</span><span class="punctuation">:</span> <span class="string">"1.26.11"</span><span class="punctuation">,</span></span><br><span class="line"> <span class="attr">"vite"</span><span class="punctuation">:</span> <span class="string">"1.0.0-rc.13"</span></span><br><span class="line"> <span class="punctuation">}</span></span><br><span class="line"><span class="punctuation">}</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>区别:</p>
<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-15_23-23-16.png" alt="Snipaste_2022-02-15_23-23-16" width="600px"></center>
</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/02/05/08/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/lion.jpg">
<meta itemprop="name" content="Xiaolong">
<meta itemprop="description" content="Never stop learning">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Xiaolong's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/02/05/08/" class="post-title-link" itemprop="url">大屏可视化项</a>
</h2>