-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss2.xml
255 lines (113 loc) · 65.2 KB
/
rss2.xml
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
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>微弱的光</title>
<link>http://shiff.top/</link>
<atom:link href="http://shiff.top/rss2.xml" rel="self" type="application/rss+xml"/>
<description>千里之行,始于足下</description>
<pubDate>Mon, 17 Jun 2024 05:32:14 GMT</pubDate>
<generator>http://hexo.io/</generator>
<item>
<title>vue中的生命周期钩子函数</title>
<link>http://shiff.top/2024/06/17/vue%E4%B8%AD%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/</link>
<guid>http://shiff.top/2024/06/17/vue%E4%B8%AD%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/</guid>
<pubDate>Mon, 17 Jun 2024 05:27:59 GMT</pubDate>
<description><h1 id="vue中的生命周期钩子函数"><a href="#vue中的生命周期钩子函数" class="headerlink" title="vue中的生命周期钩子函数"></a>vue中的生命周期钩子函数</h1><p>在 Vue 3 中,生命周期函数总体上经历了一些改变</description>
<content:encoded><![CDATA[<h1 id="vue中的生命周期钩子函数"><a href="#vue中的生命周期钩子函数" class="headerlink" title="vue中的生命周期钩子函数"></a>vue中的生命周期钩子函数</h1><p>在 Vue 3 中,生命周期函数总体上经历了一些改变,并引入了 Composition API,与 Vue 2.x 中的选项 API 有所不同。以下是 Vue 3 中常用的生命周期函数:</p><ol><li><p><strong>setup</strong>:组件创建阶段的入口,在组件实例创建之前执行,用于设置组件的初始状态、逻辑以及副作用操作等。</p></li><li><p><strong>beforeCreate</strong>:与 Vue 2.x 中的 <code>beforeCreate</code> 类似,在组件实例初始化之后,数据观测之前被调用。</p></li><li><p><strong>created</strong>:与 Vue 2.x 中的 <code>created</code> 类似,在实例创建完成后被调用,实例已完成数据观测、属性和方法运算。</p></li><li><p><strong>beforeMount</strong>:与 Vue 2.x 中的 <code>beforeMount</code> 类似,在挂载开始之前被调用,相关的 render 函数首次调用。</p></li><li><p><strong>mounted</strong>:与 Vue 2.x 中的 <code>mounted</code> 类似,在挂载结束后被调用,实例已挂载到 DOM 上。</p></li><li><p><strong>beforeUpdate</strong>:当数据更改导致虚拟 DOM 重新渲染之前调用。</p></li><li><p><strong>updated</strong>:当数据更改导致虚拟 DOM 重新渲染和打补丁后调用。</p></li><li><p><strong>beforeUnmount</strong>:在卸载组件之前调用。</p></li><li><p><strong>unmounted</strong>:在卸载组件后调用。</p></li><li><p><strong>errorCaptured</strong>:捕获组件子树中任何错误的处理器。</p></li></ol><p>除了上述生命周期函数外,Vue 3 还引入了 Composition API,开发者可以使用 <code>onMounted</code>、<code>onUpdated</code>、<code>onUnmounted</code> 等函数来实现类似生命周期钩子的功能。Composition API 提供了更灵活的方式来组织组件的逻辑。请注意,Vue 3 中的生命周期钩子函数与 Vue 2.x 中可能略有差异,主要是由于引入了 Composition API 的改变。</p>]]></content:encoded>
<category domain="http://shiff.top/tags/Vue3/">Vue3</category>
<comments>http://shiff.top/2024/06/17/vue%E4%B8%AD%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E9%92%A9%E5%AD%90%E5%87%BD%E6%95%B0/#disqus_thread</comments>
</item>
<item>
<title>使用线性渐变实现渐变背景</title>
<link>http://shiff.top/2024/06/17/%E4%BD%BF%E7%94%A8%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98%E5%AE%9E%E7%8E%B0%E6%B8%90%E5%8F%98%E8%83%8C%E6%99%AF/</link>
<guid>http://shiff.top/2024/06/17/%E4%BD%BF%E7%94%A8%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98%E5%AE%9E%E7%8E%B0%E6%B8%90%E5%8F%98%E8%83%8C%E6%99%AF/</guid>
<pubDate>Mon, 17 Jun 2024 01:57:06 GMT</pubDate>
<description><h1 id="使用线性渐变实现渐变背景"><a href="#使用线性渐变实现渐变背景" class="headerlink" title="使用线性渐变实现渐变背景"></a>使用线性渐变实现渐变背景</h1><figure class="highlight css"><ta</description>
<content:encoded><![CDATA[<h1 id="使用线性渐变实现渐变背景"><a href="#使用线性渐变实现渐变背景" class="headerlink" title="使用线性渐变实现渐变背景"></a>使用线性渐变实现渐变背景</h1><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">background-image</span>: <span class="built_in">linear-gradient</span>(<span class="number">270deg</span>, <span class="number">#f66</span>, <span class="number">#ff9f9f</span>);</span><br></pre></td></tr></table></figure><p>这段CSS代码是用于设置元素的背景图片,但是这里使用的不是传统的图像文件,而是通过线性渐变(linear gradient)来实现背景效果。让我们来解释一下这段代码的含义:</p><ol><li><p><strong><code>background-image:</code></strong> 这是CSS属性,用于设置元素的背景图片。</p></li><li><p><strong><code>linear-gradient(270deg, #f66, #ff9f9f);</code></strong> 这是具体的背景图片值,表示使用线性渐变(从一个颜色过渡到另一个颜色)来创建背景。</p></li></ol><ul><li><p><strong><code>270deg</code></strong> 表示指定线性渐变的方向为270度,即从底部到顶部的垂直方向。</p></li><li><p><strong><code>#f66</code></strong> 和 <strong><code>#ff9f9f</code></strong> 是渐变的起始色和结束色。第一个颜色 <code>#f66</code> 代表浅红色,第二个是 <code>#ff9f9f</code> 代表淡红色。在这种情况下,从底部到顶部的背景将逐渐从浅红色过渡到淡红色。</p></li></ul><p>所以,这段代码的意思是设置元素的背景为从底部到顶部的垂直线性渐变,颜色过渡从浅红色(<code>#f66</code>)到淡红色(<code>#ff9f9f</code>)。这样的效果会创建一个具有渐变色的背景,使元素看起来更加丰富和动态。</p>]]></content:encoded>
<category domain="http://shiff.top/tags/CSS/">CSS</category>
<comments>http://shiff.top/2024/06/17/%E4%BD%BF%E7%94%A8%E7%BA%BF%E6%80%A7%E6%B8%90%E5%8F%98%E5%AE%9E%E7%8E%B0%E6%B8%90%E5%8F%98%E8%83%8C%E6%99%AF/#disqus_thread</comments>
</item>
<item>
<title>Flex布局与Grid布局</title>
<link>http://shiff.top/2024/06/17/Flex%E5%B8%83%E5%B1%80%E4%B8%8EGrid%E5%B8%83%E5%B1%80/</link>
<guid>http://shiff.top/2024/06/17/Flex%E5%B8%83%E5%B1%80%E4%B8%8EGrid%E5%B8%83%E5%B1%80/</guid>
<pubDate>Mon, 17 Jun 2024 01:46:29 GMT</pubDate>
<description><h1 id="Flex布局与Grid布局"><a href="#Flex布局与Grid布局" class="headerlink" title="Flex布局与Grid布局"></a>Flex布局与Grid布局</h1><p>Grid布局和Flex布局都是在CSS中用于进行页面</description>
<content:encoded><![CDATA[<h1 id="Flex布局与Grid布局"><a href="#Flex布局与Grid布局" class="headerlink" title="Flex布局与Grid布局"></a>Flex布局与Grid布局</h1><p>Grid布局和Flex布局都是在CSS中用于进行页面布局的工具,它们各有优势和适用场景。以下是它们的一些异同点以及优缺点:</p><p><strong>异同点:</strong></p><ol><li><p><strong>相同点:</strong></p><ul><li>两者都是现代CSS布局工具,用于实现响应式布局和页面排版。</li><li>都支持对网格和弹性盒子进行灵活布局。</li><li>都可以在容器内部的子元素之间创建空间布局。</li></ul></li><li><p><strong>不同点:</strong></p><ul><li><p><strong>Flex布局(弹性布局):</strong></p><ul><li>适用于一维布局,例如在一条水平或垂直的轴线上布局元素。</li><li>适合于构建灵活的、水平或垂直居中的布局。</li><li>可以根据内容的大小来调整元素的尺寸。</li></ul></li><li><p><strong>Grid布局(网格布局):</strong></p><ul><li>适用于二维布局,可以在交叉轴上对元素进行定位,创建复杂的网格布局。</li><li>适用于规划复杂的网格结构,如页面布局的整体设计。</li><li>可以控制行与列交叉点的位置,实现更精确的布局设计。</li></ul></li></ul></li></ol><p><strong>优缺点:</strong></p><ol><li><p><strong>Flex布局优点:</strong></p><ul><li>简单实用,适合搭建基本的布局和页面结构。</li><li>支持响应式布局,更容易实现移动端适配,适合移动端开发。</li><li>配合弹性盒子布局的属性丰富,可以快速实现元素的排列和对齐。</li></ul><p><strong>缺点:</strong></p><ul><li>适用于相对简单布局,复杂的网格结构可能实现起来比较困难。</li><li>不太适合搭建复杂的多列布局。</li></ul></li><li><p><strong>Grid布局优点:</strong></p><ul><li>可以实现更复杂的网格布局,可以精确控制元素的位置和大小。</li><li>适合搭建大型网站和复杂的设计布局。</li><li>支持分区和定位,可以创建更灵活的页面结构。</li></ul><p><strong>缺点:</strong></p><ul><li>学习成本相对较高,语法相对复杂,初学者可能需要一定时间适应。</li><li>在一维布局方面不如Flex布局灵活,并不适用于所有布局场景。</li></ul></li></ol><p><strong>结论:</strong> </p><ul><li>如果页面结构相对简单,主要涉及到一维布局的元素排列和对齐,Flex布局是一个不错的选择。</li><li>如果需要实现复杂的二维布局,例如创建大型网格结构,Grid布局更适合用来实现。</li><li>在实际项目中,可以根据具体需求和布局复杂度来选择合适的布局方法,有时候也可以结合使用两者来实现更灵活和多样化的布局效果。</li></ul>]]></content:encoded>
<category domain="http://shiff.top/categories/CSS/">CSS</category>
<category domain="http://shiff.top/tags/CSS/">CSS</category>
<comments>http://shiff.top/2024/06/17/Flex%E5%B8%83%E5%B1%80%E4%B8%8EGrid%E5%B8%83%E5%B1%80/#disqus_thread</comments>
</item>
<item>
<title>文本的截断和显示控制</title>
<link>http://shiff.top/2024/06/16/%E6%96%87%E6%9C%AC%E7%9A%84%E6%88%AA%E6%96%AD%E5%92%8C%E6%98%BE%E7%A4%BA%E6%8E%A7%E5%88%B6/</link>
<guid>http://shiff.top/2024/06/16/%E6%96%87%E6%9C%AC%E7%9A%84%E6%88%AA%E6%96%AD%E5%92%8C%E6%98%BE%E7%A4%BA%E6%8E%A7%E5%88%B6/</guid>
<pubDate>Sun, 16 Jun 2024 15:32:11 GMT</pubDate>
<description><h1 id="文本的截断和显示控制"><a href="#文本的截断和显示控制" class="headerlink" title="文本的截断和显示控制"></a>文本的截断和显示控制</h1><p>下面三个属性通常用于在Web开发中对文本进行截断和显示控制,主要用于控制文本</description>
<content:encoded><![CDATA[<h1 id="文本的截断和显示控制"><a href="#文本的截断和显示控制" class="headerlink" title="文本的截断和显示控制"></a>文本的截断和显示控制</h1><p>下面三个属性通常用于在Web开发中对文本进行截断和显示控制,主要用于控制文本在容器中的显示方式。具体含义如下:</p><ol><li><p><code>display: -webkit-box;</code>:这个属性用于指定元素应该生成一个块级容器框。在这种布局模型中,元素是一个块级容器,可以在内部容纳其他元素。在这种情况下,通常需要与其他属性结合使用。</p></li><li><p><code>-webkit-line-clamp: 2;</code>:这个属性用于指定显示的行数限制。在文本溢出时,只显示指定行数的文本内容。上面的例子中,只显示不超过两行的文本内容。</p></li><li><p><code> -webkit-box-orient: vertical;</code>:这个属性用于指定盒子的排列方向。在这种情况下,盒子内的元素垂直排列。</p></li></ol><p>这些属性通常与前缀 <code>-webkit-</code> 一起使用,表示这些属性是Webkit浏览器专有的CSS扩展。这些属性主要用于控制元素的显示方式,特别是在限制文本显示行数和盒子内元素排列方向方面。</p>]]></content:encoded>
<category domain="http://shiff.top/tags/CSS/">CSS</category>
<comments>http://shiff.top/2024/06/16/%E6%96%87%E6%9C%AC%E7%9A%84%E6%88%AA%E6%96%AD%E5%92%8C%E6%98%BE%E7%A4%BA%E6%8E%A7%E5%88%B6/#disqus_thread</comments>
</item>
<item>
<title>text-overflow的用法</title>
<link>http://shiff.top/2024/06/14/text-overflow%E7%9A%84%E7%94%A8%E6%B3%95/</link>
<guid>http://shiff.top/2024/06/14/text-overflow%E7%9A%84%E7%94%A8%E6%B3%95/</guid>
<pubDate>Fri, 14 Jun 2024 10:15:57 GMT</pubDate>
<description><h1 id="text-overflow的用法"><a href="#text-overflow的用法" class="headerlink" title="text-overflow的用法"></a>text-overflow的用法</h1><p><code>text-ove</description>
<content:encoded><![CDATA[<h1 id="text-overflow的用法"><a href="#text-overflow的用法" class="headerlink" title="text-overflow的用法"></a>text-overflow的用法</h1><p><code>text-overflow</code>是CSS样式属性,用于控制当文本溢出容器时如何显示。</p><p>常见的取值有:</p><ul><li><code>clip</code>:默认值,表示将溢出的部分隐藏。</li><li><code>ellipsis</code>:表示将溢出的文本显示为省略号(…)。</li><li><code>inherit</code>:继承父元素的文本溢出样式。</li></ul><p>示例:</p><figure class="highlight css"><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="selector-class">.text-ellipsis</span> {</span><br><span class="line"> <span class="attribute">white-space</span>: nowrap; <span class="comment">/* 不换行 */</span></span><br><span class="line"> <span class="attribute">overflow</span>: hidden; <span class="comment">/* 溢出隐藏 */</span></span><br><span class="line"> <span class="attribute">text-overflow</span>: ellipsis; <span class="comment">/* 超出部分以省略号显示 */</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>在上面的示例中,当文本内容超出容器的宽度时,将以省略号的形式显示。需要注意的是,通常需要配合<code>white-space: nowrap;</code>和<code>overflow: hidden;</code>这两个样式属性一起使用,来确保省略号的效果正常显示。</p><p><code>text-overflow</code>通常用于单行文本或者内联元素,对于多行文本或块级元素,更适合使用<code>-webkit-line-clamp</code>结合<code>-webkit-box</code>来实现类似的效果。</p>]]></content:encoded>
<comments>http://shiff.top/2024/06/14/text-overflow%E7%9A%84%E7%94%A8%E6%B3%95/#disqus_thread</comments>
</item>
<item>
<title>less中的&符号</title>
<link>http://shiff.top/2024/06/14/less%E4%B8%AD%E7%9A%84&%E7%AC%A6%E5%8F%B7/</link>
<guid>http://shiff.top/2024/06/14/less%E4%B8%AD%E7%9A%84&%E7%AC%A6%E5%8F%B7/</guid>
<pubDate>Fri, 14 Jun 2024 03:23:54 GMT</pubDate>
<description><h1 id="less中的-amp-符号"><a href="#less中的-amp-符号" class="headerlink" title="less中的&amp;符号"></a>less中的&amp;符号</h1><p>在 Less 预处理器中,<code>&amp;</</description>
<content:encoded><![CDATA[<h1 id="less中的-amp-符号"><a href="#less中的-amp-符号" class="headerlink" title="less中的&符号"></a>less中的&符号</h1><p>在 Less 预处理器中,<code>&</code> 符号用于引用当前选择器的父级。这在嵌套规则中非常有用,可以帮助生成更复杂的选择器,而不需要重复父选择器的名称。</p><h3 id="基本用法"><a href="#基本用法" class="headerlink" title="基本用法"></a>基本用法</h3><p>在 Less 中,<code>&</code> 符号代表父选择器,可以用来构建更复杂的选择器规则。例如:</p><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">color</span>: black;</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">::before</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">"Prefix"</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>编译后的 CSS 如下:</p><figure class="highlight css"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">color</span>: black;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.container</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.container</span><span class="selector-pseudo">::before</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">"Prefix"</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h3 id="具体示例"><a href="#具体示例" class="headerlink" title="具体示例"></a>具体示例</h3><p>以下是一些常见的 <code>&</code> 符号用法示例:</p><h4 id="1-伪类和伪元素"><a href="#1-伪类和伪元素" class="headerlink" title="1. 伪类和伪元素"></a>1. 伪类和伪元素</h4><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.button</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: green;</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: darkgreen;</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-pseudo">::after</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">" (hover me)"</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>编译后的 CSS:</p><figure class="highlight css"><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="selector-class">.button</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: green;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.button</span><span class="selector-pseudo">:hover</span> {</span><br><span class="line"> <span class="attribute">background-color</span>: darkgreen;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.button</span><span class="selector-pseudo">::after</span> {</span><br><span class="line"> <span class="attribute">content</span>: <span class="string">" (hover me)"</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h4 id="2-子选择器"><a href="#2-子选择器" class="headerlink" title="2. 子选择器"></a>2. 子选择器</h4><figure class="highlight less"><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="selector-class">.nav</span> {</span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-tag">-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: red;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>编译后的 CSS:</p><figure class="highlight css"><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="selector-class">.nav-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: red;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h4 id="3-父选择器引用"><a href="#3-父选择器引用" class="headerlink" title="3. 父选择器引用"></a>3. 父选择器引用</h4><figure class="highlight less"><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="selector-class">.list</span> {</span><br><span class="line"> <span class="selector-class">.list-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line"> </span><br><span class="line"> <span class="selector-tag">&</span><span class="selector-class">.active</span> {</span><br><span class="line"> <span class="attribute">color</span>: darkblue;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>编译后的 CSS:</p><figure class="highlight css"><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="selector-class">.list</span> <span class="selector-class">.list-item</span> {</span><br><span class="line"> <span class="attribute">color</span>: blue;</span><br><span class="line">}</span><br><span class="line"><span class="selector-class">.list</span> <span class="selector-class">.list-item</span><span class="selector-class">.active</span> {</span><br><span class="line"> <span class="attribute">color</span>: darkblue;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h4 id="4-嵌套媒体查询"><a href="#4-嵌套媒体查询" class="headerlink" title="4. 嵌套媒体查询"></a>4. 嵌套媒体查询</h4><figure class="highlight less"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">100%</span>;</span><br><span class="line"> </span><br><span class="line"> <span class="keyword">@media</span> (<span class="attribute">min-width</span>: <span class="number">768px</span>) {</span><br><span class="line"> <span class="selector-tag">&</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">50%</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>编译后的 CSS:</p><figure class="highlight css"><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></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">100%</span>;</span><br><span class="line">}</span><br><span class="line"><span class="keyword">@media</span> (<span class="attribute">min-width</span>: <span class="number">768px</span>) {</span><br><span class="line"> <span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">50%</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p><code>&</code> 符号在 Less 中非常强大,可以帮助你避免重复代码,并使样式表更具可读性和可维护性。通过合理使用 <code>&</code> 符号,可以轻松创建复杂的选择器规则,提升 CSS 编写的效率和灵活性。</p>]]></content:encoded>
<category domain="http://shiff.top/tags/Less/">Less</category>
<comments>http://shiff.top/2024/06/14/less%E4%B8%AD%E7%9A%84&%E7%AC%A6%E5%8F%B7/#disqus_thread</comments>
</item>
<item>
<title>overflow的用法</title>
<link>http://shiff.top/2024/06/14/overflow%E7%9A%84%E7%94%A8%E6%B3%95/</link>
<guid>http://shiff.top/2024/06/14/overflow%E7%9A%84%E7%94%A8%E6%B3%95/</guid>
<pubDate>Fri, 14 Jun 2024 03:05:16 GMT</pubDate>
<description><h1 id="Overflow的用法"><a href="#Overflow的用法" class="headerlink" title="Overflow的用法"></a>Overflow的用法</h1><p><code>overflow</code> 是 CSS 中的一个属性</description>
<content:encoded><![CDATA[<h1 id="Overflow的用法"><a href="#Overflow的用法" class="headerlink" title="Overflow的用法"></a>Overflow的用法</h1><p><code>overflow</code> 是 CSS 中的一个属性,用于控制元素内容在水平方向和垂直方向上的溢出行为。它决定了当内容溢出元素的尺寸时,是否显示滚动条、截断内容或其他处理方式。</p><h3 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">overflow</span>: visible | hidden | scroll | auto;</span><br></pre></td></tr></table></figure><h3 id="属性值"><a href="#属性值" class="headerlink" title="属性值"></a>属性值</h3><ul><li><code>visible</code>:默认值。内容不会被剪裁,会呈现在元素框之外。</li><li><code>hidden</code>:溢出内容会被剪裁(隐藏),不会显示滚动条。</li><li><code>scroll</code>:无论内容是否溢出,都会显示滚动条。</li><li><code>auto</code>:如果内容溢出,浏览器会自动显示滚动条。</li></ul><h3 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h3><p>假设有一个包含大量文本的容器:</p><figure class="highlight html"><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="tag"><<span class="name">div</span> <span class="attr">class</span>=<span class="string">"container"</span>></span></span><br><span class="line"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.</span><br><span class="line"><span class="tag"></<span class="name">div</span>></span></span><br></pre></td></tr></table></figure><p>CSS 代码如下:</p><figure class="highlight css"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: auto; <span class="comment">/* 自动显示滚动条 */</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>在这个例子中:</p><ul><li>当容器的内容宽度或高度超过 200px 或 100px 时,浏览器会自动显示水平或垂直滚动条,以便用户可以滚动查看内容。</li></ul><h3 id="各属性值示例"><a href="#各属性值示例" class="headerlink" title="各属性值示例"></a>各属性值示例</h3><ol><li><code>visible</code>:</li></ol><figure class="highlight css"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: visible;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>内容会溢出容器,不会显示滚动条。</p><ol start="2"><li><code>hidden</code>:</li></ol><figure class="highlight css"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: hidden;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>内容会被剪裁,溢出部分不可见,不会显示滚动条。</p><ol start="3"><li><code>scroll</code>:</li></ol><figure class="highlight css"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: scroll;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>无论内容是否溢出,都会显示滚动条。</p><ol start="4"><li><code>auto</code>:</li></ol><figure class="highlight css"><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="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow</span>: auto;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>当内容溢出时,浏览器会自动显示滚动条。</p><h3 id="组合使用-overflow-x-和-overflow-y"><a href="#组合使用-overflow-x-和-overflow-y" class="headerlink" title="组合使用 overflow-x 和 overflow-y"></a>组合使用 <code>overflow-x</code> 和 <code>overflow-y</code></h3><p>有时你可能需要分别控制水平方向和垂直方向的溢出行为,这时可以使用 <code>overflow-x</code> 和 <code>overflow-y</code> 属性。</p><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span> {</span><br><span class="line"> <span class="attribute">width</span>: <span class="number">200px</span>;</span><br><span class="line"> <span class="attribute">height</span>: <span class="number">100px</span>;</span><br><span class="line"> <span class="attribute">border</span>: <span class="number">1px</span> solid black;</span><br><span class="line"> <span class="attribute">overflow-x</span>: auto; <span class="comment">/* 水平方向自动显示滚动条 */</span></span><br><span class="line"> <span class="attribute">overflow-y</span>: hidden; <span class="comment">/* 垂直方向隐藏溢出内容 */</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure><h3 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h3><ul><li><code>overflow</code> 属性仅在元素具有限定的宽度和高度时起作用。</li><li><code>overflow</code> 属性常用于创建滚动区域,特别是在布局响应式设计中。</li></ul><p>通过合理使用 <code>overflow</code> 属性,可以更好地控制元素内容在水平方向和垂直方向上的显示方式,提升页面的可读性和用户体验。</p>]]></content:encoded>
<category domain="http://shiff.top/tags/CSS/">CSS</category>
<comments>http://shiff.top/2024/06/14/overflow%E7%9A%84%E7%94%A8%E6%B3%95/#disqus_thread</comments>
</item>
<item>
<title>Axios学习</title>
<link>http://shiff.top/2024/05/24/Axios%E5%AD%A6%E4%B9%A0/</link>
<guid>http://shiff.top/2024/05/24/Axios%E5%AD%A6%E4%B9%A0/</guid>
<pubDate>Fri, 24 May 2024 08:32:36 GMT</pubDate>
<description><h1 id="Axiso库"><a href="#Axiso库" class="headerlink" title="Axiso库"></a>Axiso库</h1><p><strong>官方介绍:</strong></p>
<p>Axios 是一个基于 <em><a href=</description>
<content:encoded><![CDATA[<h1 id="Axiso库"><a href="#Axiso库" class="headerlink" title="Axiso库"></a>Axiso库</h1><p><strong>官方介绍:</strong></p><p>Axios 是一个基于 <em><a href="https://javascript.info/promise-basics">promise</a></em> 网络请求库,作用于<a href="https://nodejs.org/"><code>node.js</code></a> 和浏览器中。 它是 <em><a href="https://www.lullabot.com/articles/what-is-an-isomorphic-application">isomorphic</a></em> 的(即同一套代码可以运行在浏览器和node.js中)。在服务端它使用原生 node.js <code>http</code> 模块, 而在客户端 (浏览端) 则使用 XMLHttpRequests。</p><p><strong>axios官方文档:</strong><a href="https://www.axios-http.cn/docs/intro">https://www.axios-http.cn/docs/intro</a></p><h2 id="更新"><a href="#更新" class="headerlink" title="更新"></a>更新</h2><p>2024.5.24 第一次更新,主要学习了一下Axiso的基本用法</p><h2 id="功能特点"><a href="#功能特点" class="headerlink" title="功能特点"></a>功能特点</h2><ul><li><p>在浏览器中发送XMLHttpRequest请求</p><blockquote><p>避免了兼容性问题,fech是存在兼容性问题的</p></blockquote></li><li><p>在node.js中发送http请求</p><blockquote><p>不需要关心在不同的环境用不同的API,axiso会自动识别环境,在不同的环境下用的都是同一个API</p></blockquote></li><li><p>支持 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a> API</p></li><li><p>拦截请求和响应</p></li><li><p>转换请求和响应数据</p></li><li><p>取消请求</p></li><li><p>超时处理</p></li><li><p>查询参数序列化支持嵌套项处理</p></li><li><p>自动将请求体序列化为:</p><ul><li>JSON (<code>application/json</code>)</li><li>Multipart / FormData (<code>multipart/form-data</code>)</li><li>URL encoded form (<code>application/x-www-form-urlencoded</code>)</li></ul></li><li><p>将 HTML Form 转换成 JSON 进行请求</p></li><li><p>自动转换JSON数据</p></li><li><p>获取浏览器和 node.js 的请求进度,并提供额外的信息(速度、剩余时间)</p></li><li><p>为 node.js 设置带宽限制</p></li></ul><h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><blockquote><p>npm install axios</p></blockquote><h2 id="在需要使用的js文件中引入axios"><a href="#在需要使用的js文件中引入axios" class="headerlink" title="在需要使用的js文件中引入axios"></a>在需要使用的js文件中引入axios</h2><blockquote><p>import axios from ‘axios’</p></blockquote><h2 id="axios请求方法"><a href="#axios请求方法" class="headerlink" title="axios请求方法"></a>axios请求方法</h2><h3 id="config请求配置"><a href="#config请求配置" class="headerlink" title="config请求配置"></a>config请求配置</h3><ul><li><p>url: <code>url</code> 是用于请求的服务器 URL</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="attr">url</span>: <span class="string">'/user'</span>,</span><br></pre></td></tr></table></figure></li><li><p>method:<code>method</code> 是创建请求时使用的方法</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="attr">method</span>: <span class="string">'get'</span>, <span class="comment">// 默认值</span></span><br></pre></td></tr></table></figure></li><li><p>baseURL: <code>baseURL</code> 将自动加在 <code>url</code> 前面,除非 <code>url</code> 是一个绝对 URL。<br>它可以通过设置一个 <code>baseURL</code> 便于为 axios 实例的方法传递相对 URL</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="comment">// `baseURL` 将自动加在 `url` 前面,除非 `url` 是一个绝对 URL。</span></span><br><span class="line"> <span class="comment">// 它可以通过设置一个 `baseURL` 便于为 axios 实例的方法传递相对 URL</span></span><br><span class="line"> <span class="attr">baseURL</span>: <span class="string">'https://some-domain.com/api/'</span>,</span><br></pre></td></tr></table></figure></li><li><p>transformRequest: <code>transformRequest</code> 允许在向服务器发送前,修改请求数据。</p><ul><li>它只能用于 ‘PUT’, ‘POST’ 和 ‘PATCH’ 这几个请求方法。</li><li>数组中最后一个函数必须返回一个字符串, 一个Buffer实例,ArrayBuffer,FormData,或 Stream。</li><li>你可以修改请求头。</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></pre></td><td class="code"><pre><span class="line"><span class="attr">transformRequest</span>: [<span class="keyword">function</span> (<span class="params">data, headers</span>) {</span><br><span class="line"> <span class="comment">// 对发送的 data 进行任意转换处理</span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">return</span> data;</span><br><span class="line"> }],</span><br></pre></td></tr></table></figure></li><li><p>transformResponse:<code>transformResponse</code> 在传递给 then/catch 前,允许修改响应数据</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></pre></td><td class="code"><pre><span class="line"><span class="attr">transformResponse</span>: [<span class="keyword">function</span> (<span class="params">data</span>) {</span><br><span class="line"> <span class="comment">// 对接收的 data 进行任意转换处理</span></span><br><span class="line"> <span class="keyword">return</span> data;</span><br><span class="line"> }],</span><br></pre></td></tr></table></figure></li><li><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="attr">headers</span>: {<span class="string">'X-Requested-With'</span>: <span class="string">'XMLHttpRequest'</span>},</span><br></pre></td></tr></table></figure></li><li><p>params:<code>params</code> 是与请求一起发送的 URL 参数,必须是一个简单对象或 URLSearchParams 对象</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="attr">params</span>: {</span><br><span class="line"> <span class="attr">ID</span>: <span class="number">12345</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure></li><li><p>paramsSerializer:<code>paramsSerializer</code>是可选方法,主要用于序列化<code>params</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></pre></td><td class="code"><pre><span class="line"><span class="attr">paramsSerializer</span>: <span class="keyword">function</span> (<span class="params">params</span>) {</span><br><span class="line"> <span class="keyword">return</span> <span class="title class_">Qs</span>.<span class="title function_">stringify</span>(params, {<span class="attr">arrayFormat</span>: <span class="string">'brackets'</span>})</span><br><span class="line"> },</span><br></pre></td></tr></table></figure></li><li><p>data:<code>data</code> 是作为请求体被发送的数据</p><ul><li>仅适用 ‘PUT’, ‘POST’, ‘DELETE 和 ‘PATCH’ 请求方法</li><li>在没有设置 <code>transformRequest</code> 时,则必须是以下类型之一:<ul><li>string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams</li><li>浏览器专属: FormData, File, Blob</li><li>Node 专属: Stream, Buffer</li></ul></li></ul></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></pre></td><td class="code"><pre><span class="line"><span class="attr">data</span>: {</span><br><span class="line"> <span class="attr">firstName</span>: <span class="string">'Fred'</span></span><br><span class="line">},</span><br></pre></td></tr></table></figure><ul><li>timeout:<code>timeout</code> 指定请求超时的毫秒数。</li></ul><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="comment">// 如果请求时间超过 `timeout` 的值,则请求会被中断</span></span><br><span class="line"><span class="attr">timeout</span>: <span class="number">1000</span>, <span class="comment">// 默认值是 `0` (永不超时)</span></span><br></pre></td></tr></table></figure><ul><li><p>withCredentials:<code>withCredentials</code> 表示跨域请求时是否需要使用凭证</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="attr">withCredentials</span>: <span class="literal">false</span>, <span class="comment">// default</span></span><br></pre></td></tr></table></figure></li><li><p>adapter:<code>adapter</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></pre></td><td class="code"><pre><span class="line"><span class="comment">//返回一个 promise 并提供一个有效的响应</span></span><br><span class="line"><span class="attr">adapter</span>: <span class="keyword">function</span> (<span class="params">config</span>) {</span><br><span class="line"> <span class="comment">/* ... */</span></span><br><span class="line">},</span><br></pre></td></tr></table></figure></li><li><p>responseEncoding:<code>responseEncoding</code> 表示用于解码响应的编码 (Node.js 专属)</p><blockquote><p>注意:忽略 <code>responseType</code> 的值为 ‘stream’,或者是客户端请求</p></blockquote></li></ul><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="attr">responseEncoding</span>: <span class="string">'utf8'</span>, <span class="comment">// 默认值</span></span><br></pre></td></tr></table></figure><p>更多参数,查询:<a href="https://www.axios-http.cn/docs/req_config">https://www.axios-http.cn/docs/req_config</a></p><h3 id="axios"><a href="#axios" class="headerlink" title="axios"></a>axios</h3><p><code>axios(config)</code></p><h5 id="axios-config-——post请求"><a href="#axios-config-——post请求" class="headerlink" title="axios(config)——post请求"></a>axios(config)——<strong>post请求</strong></h5><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 发起一个post请求</span></span><br><span class="line"><span class="title function_">axios</span>({</span><br><span class="line"> <span class="attr">method</span>: <span class="string">'post'</span>,</span><br><span class="line"> <span class="attr">url</span>: <span class="string">'/user/12345'</span>,</span><br><span class="line"> <span class="attr">data</span>: {</span><br><span class="line"> <span class="attr">firstName</span>: <span class="string">'Fred'</span>,</span><br><span class="line"> <span class="attr">lastName</span>: <span class="string">'Flintstone'</span></span><br><span class="line"> }</span><br><span class="line">});</span><br></pre></td></tr></table></figure><h5 id="axios-config-——get请求"><a href="#axios-config-——get请求" class="headerlink" title="axios(config)——get请求"></a>axios(config)——<strong>get请求</strong></h5><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></pre></td><td class="code"><pre><span class="line"><span class="comment">// 在 node.js 用GET请求获取远程图片</span></span><br><span class="line"><span class="title function_">axios</span>({</span><br><span class="line"> <span class="attr">method</span>: <span class="string">'get'</span>,</span><br><span class="line"> <span class="attr">url</span>: <span class="string">'http://bit.ly/2mTM3nY'</span>,</span><br><span class="line"> <span class="attr">responseType</span>: <span class="string">'stream'</span></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"> response.<span class="property">data</span>.<span class="title function_">pipe</span>(fs.<span class="title function_">createWriteStream</span>(<span class="string">'ada_lovelace.jpg'</span>))</span><br><span class="line"> });</span><br></pre></td></tr></table></figure><h5 id="axios-url-config"><a href="#axios-url-config" class="headerlink" title="axios(url[, config])"></a>axios(url[, config])</h5><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="comment">// 发起一个 GET 请求 (默认请求方式)</span></span><br><span class="line"><span class="title function_">axios</span>(<span class="string">'/user/12345'</span>);</span><br></pre></td></tr></table></figure><h3 id="请求别名"><a href="#请求别名" class="headerlink" title="请求别名"></a>请求别名</h3><h5 id="axios-request-config"><a href="#axios-request-config" class="headerlink" title="axios.request(config)"></a>axios.request(config)<a href="https://www.axios-http.cn/docs/api_intro#axiosrequestconfig"></a></h5><h5 id="axios-get-url-config"><a href="#axios-get-url-config" class="headerlink" title="axios.get(url[, config])"></a>axios.get(url[, config])<a href="https://www.axios-http.cn/docs/api_intro#axiosgeturl-config"></a></h5><h5 id="axios-delete-url-config"><a href="#axios-delete-url-config" class="headerlink" title="axios.delete(url[, config])"></a>axios.delete(url[, config])<a href="https://www.axios-http.cn/docs/api_intro#axiosdeleteurl-config"></a></h5><h5 id="axios-head-url-config"><a href="#axios-head-url-config" class="headerlink" title="axios.head(url[, config])"></a>axios.head(url[, config])<a href="https://www.axios-http.cn/docs/api_intro#axiosheadurl-config"></a></h5><h5 id="axios-options-url-config"><a href="#axios-options-url-config" class="headerlink" title="axios.options(url[, config])"></a>axios.options(url[, config])<a href="https://www.axios-http.cn/docs/api_intro#axiosoptionsurl-config"></a></h5><h5 id="axios-post-url-data-config"><a href="#axios-post-url-data-config" class="headerlink" title="axios.post(url[, data[, config]])"></a>axios.post(url[, data[, config]])<a href="https://www.axios-http.cn/docs/api_intro#axiosposturl-data-config"></a></h5><h5 id="axios-put-url-data-config"><a href="#axios-put-url-data-config" class="headerlink" title="axios.put(url[, data[, config]])"></a>axios.put(url[, data[, config]])<a href="https://www.axios-http.cn/docs/api_intro#axiosputurl-data-config"></a></h5><h5 id="axios-patch-url-data-config"><a href="#axios-patch-url-data-config" class="headerlink" title="axios.patch(url[, data[, config]])"></a>axios.patch(url[, data[, config]])<a href="https://www.axios-http.cn/docs/api_intro#axiospatchurl-data-config"></a></h5><h5 id="axios-postForm-url-data-config"><a href="#axios-postForm-url-data-config" class="headerlink" title="axios.postForm(url[, data[, config]])"></a>axios.postForm(url[, data[, config]])<a href="https://www.axios-http.cn/docs/api_intro#axiospostformurl-data-config"></a></h5><h5 id="axios-putForm-url-data-config"><a href="#axios-putForm-url-data-config" class="headerlink" title="axios.putForm(url[, data[, config]])"></a>axios.putForm(url[, data[, config]])<a href="https://www.axios-http.cn/docs/api_intro#axiosputformurl-data-config"></a></h5><h5 id="axios-patchForm-url-data-config"><a href="#axios-patchForm-url-data-config" class="headerlink" title="axios.patchForm(url[, data[, config]])"></a>axios.patchForm(url[, data[, config]])</h5><h3 id="常用的两个"><a href="#常用的两个" class="headerlink" title="常用的两个"></a>常用的两个</h3><h4 id="axios-get"><a href="#axios-get" class="headerlink" title="axios.get"></a>axios.get</h4><h4 id="axios-post"><a href="#axios-post" class="headerlink" title="axios.post"></a>axios.post</h4><p>Url:请求地址</p><p>data:请求体</p><p>config:配置</p><h3 id=""><a href="#" class="headerlink" title=""></a></h3>]]></content:encoded>
<category domain="http://shiff.top/tags/Axios/">Axios</category>
<comments>http://shiff.top/2024/05/24/Axios%E5%AD%A6%E4%B9%A0/#disqus_thread</comments>
</item>
<item>
<title>vscode快捷键(mac中)</title>
<link>http://shiff.top/2024/05/23/vscode%E5%BF%AB%E6%8D%B7%E9%94%AE/</link>
<guid>http://shiff.top/2024/05/23/vscode%E5%BF%AB%E6%8D%B7%E9%94%AE/</guid>
<pubDate>Thu, 23 May 2024 02:38:13 GMT</pubDate>
<description><h1 id="vscode快捷键-mac中"><a href="#vscode快捷键-mac中" class="headerlink" title="vscode快捷键(mac中)"></a>vscode快捷键(mac中)</h1><h3 id="缩进"><a href="#缩</description>
<content:encoded><![CDATA[<h1 id="vscode快捷键-mac中"><a href="#vscode快捷键-mac中" class="headerlink" title="vscode快捷键(mac中)"></a>vscode快捷键(mac中)</h1><h3 id="缩进"><a href="#缩进" class="headerlink" title="缩进"></a>缩进</h3><p>选中需要缩进的行,按住 <code>Command+]</code> 键。</p>]]></content:encoded>
<category domain="http://shiff.top/tags/%E5%AE%9E%E8%B7%B5/">实践</category>
<comments>http://shiff.top/2024/05/23/vscode%E5%BF%AB%E6%8D%B7%E9%94%AE/#disqus_thread</comments>
</item>
<item>
<title>Vue-父子组件的通信</title>
<link>http://shiff.top/2024/05/18/Vue-%E7%88%B6%E5%AD%90%E7%BB%84%E4%BB%B6%E7%9A%84%E9%80%9A%E4%BF%A1/</link>
<guid>http://shiff.top/2024/05/18/Vue-%E7%88%B6%E5%AD%90%E7%BB%84%E4%BB%B6%E7%9A%84%E9%80%9A%E4%BF%A1/</guid>
<pubDate>Sat, 18 May 2024 04:38:30 GMT</pubDate>
<description><h1 id="Vue-父子组件的通信"><a href="#Vue-父子组件的通信" class="headerlink" title="Vue-父子组件的通信"></a>Vue-父子组件的通信</h1><p>在 Vue.js 中,父子组件之间的通信可以通过 props 和 e</description>
<content:encoded><![CDATA[<h1 id="Vue-父子组件的通信"><a href="#Vue-父子组件的通信" class="headerlink" title="Vue-父子组件的通信"></a>Vue-父子组件的通信</h1><p>在 Vue.js 中,父子组件之间的通信可以通过 props 和 events 来实现。下面分别介绍了 props 和 events 的用法:</p><h3 id="使用-Props(父传子):"><a href="#使用-Props(父传子):" class="headerlink" title="使用 Props(父传子):"></a>使用 Props(父传子):</h3><ul><li>父组件可以通过 props 向子组件传递数据。</li><li>在子组件中,props 是响应式的,即当父组件的数据发生变化时,子组件会自动更新。</li><li>父组件通过在子组件上使用属性绑定的方式传递数据。</li></ul><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></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <ChildComponent :message="parentMessage" /></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script></span><br><span class="line">import ChildComponent from './ChildComponent.vue';</span><br><span class="line"></span><br><span class="line">export default {</span><br><span class="line"> data() {</span><br><span class="line"> return {</span><br><span class="line"> parentMessage: 'Hello from Parent',</span><br><span class="line"> };</span><br><span class="line"> },</span><br><span class="line"> components: {</span><br><span class="line"> ChildComponent,</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></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <div>{{ message }}</div></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"> props: ['message'],</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure><h3 id="使用-Events(子传父):"><a href="#使用-Events(子传父):" class="headerlink" title="使用 Events(子传父):"></a>使用 Events(子传父):</h3><ul><li>子组件可以通过 events 向父组件发送消息。</li><li>在子组件中使用 <code>$emit</code> 方法触发一个自定义事件,并传递数据。</li><li>父组件通过在子组件上监听自定义事件来接收子组件发送的消息。</li></ul><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></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <ChildComponent @child-event="handleChildEvent" /></span><br><span class="line"></template></span><br><span class="line"></span><br><span class="line"><script></span><br><span class="line">import ChildComponent from './ChildComponent.vue';</span><br><span class="line"></span><br><span class="line">export default {</span><br><span class="line"> methods: {</span><br><span class="line"> handleChildEvent(data) {</span><br><span class="line"> console.log('Received data from child:', data);</span><br><span class="line"> },</span><br><span class="line"> },</span><br><span class="line"> components: {</span><br><span class="line"> ChildComponent,</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></pre></td><td class="code"><pre><span class="line"><template></span><br><span class="line"> <button @click="sendMessage">Send Message to Parent</button></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"> methods: {</span><br><span class="line"> sendMessage() {</span><br><span class="line"> this.$emit('child-event', 'Hello from Child');</span><br><span class="line"> },</span><br><span class="line"> },</span><br><span class="line">};</span><br><span class="line"></script></span><br></pre></td></tr></table></figure><p>通过 props 和 events,父子组件之间可以方便地进行通信,实现数据的传递和交互。</p>]]></content:encoded>
<comments>http://shiff.top/2024/05/18/Vue-%E7%88%B6%E5%AD%90%E7%BB%84%E4%BB%B6%E7%9A%84%E9%80%9A%E4%BF%A1/#disqus_thread</comments>
</item>
</channel>
</rss>