2121``` html
2222<template >
2323 <div >
24- <el-x-typewriter :content =" basicContent" :typing =" true" ref =" basicDemo" />
24+ <el-x-typewriter
25+ :content =" basicContent"
26+ :typing =" true"
27+ ref =" basicDemo"
28+ />
2529
2630 <div class =" demo-controls" >
2731 <el-button-group >
28- <el-button size =" small" type =" primary" @click =" startBasic"
29- >预览</el-button
32+ <el-button
33+ size =" small"
34+ type =" primary"
35+ @click =" startBasic"
36+ >
37+ 预览
38+ </el-button >
39+ <el-button
40+ size =" small"
41+ @click =" resetBasic"
3042 >
31- <el-button size =" small" @click =" resetBasic" >重置</el-button >
43+ 重置
44+ </el-button >
3245 </el-button-group >
3346 </div >
3447 </div >
3851 export default {
3952 data () {
4053 return {
41- basicContent:
42- " 这是一个基础打字效果演示,展示Typewriter组件的基本功能。" ,
54+ basicContent: ' 这是一个基础打字效果演示,展示Typewriter组件的基本功能。' ,
4355 };
4456 },
4557 methods: {
102114 />
103115
104116 <div class =" demo-controls" >
105- <el-button size =" small" type =" primary" @click =" startSpeedDemo"
106- >预览</el-button
117+ <el-button
118+ size =" small"
119+ type =" primary"
120+ @click =" startSpeedDemo"
107121 >
122+ 预览
123+ </el-button >
108124 </div >
109125 </div >
110126</template >
114130 data () {
115131 return {
116132 speedContent:
117- " 通过配置可以调整打字速度和每次打字的字符数,实现不同的打字效果。速度越慢,interval值越大;步长越大,每次显示的字符越多。" ,
133+ ' 通过配置可以调整打字速度和每次打字的字符数,实现不同的打字效果。速度越慢,interval值越大;步长越大,每次显示的字符越多。' ,
118134 typingConfig: {
119135 interval: 40 ,
120136 step: 2 ,
121- suffix: " | " ,
137+ suffix: ' | ' ,
122138 },
123139 };
124140 },
165181 placeholder =" 选择光标字符"
166182 style =" width : 120px ;"
167183 >
168- <el-option label =" |" value =" |" ></el-option >
169- <el-option label =" _" value =" _" ></el-option >
170- <el-option label =" ❚" value =" ❚" ></el-option >
171- <el-option label =" ▊" value =" ▊" ></el-option >
172- <el-option label =" ➤" value =" ➤" ></el-option >
173- <el-option label =" 😊" value =" 😊" ></el-option >
184+ <el-option
185+ label =" |"
186+ value =" |"
187+ ></el-option >
188+ <el-option
189+ label =" _"
190+ value =" _"
191+ ></el-option >
192+ <el-option
193+ label =" ❚"
194+ value =" ❚"
195+ ></el-option >
196+ <el-option
197+ label =" ▊"
198+ value =" ▊"
199+ ></el-option >
200+ <el-option
201+ label =" ➤"
202+ value =" ➤"
203+ ></el-option >
204+ <el-option
205+ label =" 😊"
206+ value =" 😊"
207+ ></el-option >
174208 </el-select >
175209 </div >
176210 </div >
182216 />
183217
184218 <div class =" demo-controls" >
185- <el-button size =" small" type =" primary" @click =" startCursorDemo"
186- >预览</el-button
219+ <el-button
220+ size =" small"
221+ type =" primary"
222+ @click =" startCursorDemo"
187223 >
224+ 预览
225+ </el-button >
188226 </div >
189227 </div >
190228</template >
193231 export default {
194232 data () {
195233 return {
196- cursorContent:
197- " 通过自定义光标字符,可以实现不同的视觉效果。尝试切换不同的光标字符来体验。" ,
198- cursorChar: " |" ,
234+ cursorContent: ' 通过自定义光标字符,可以实现不同的视觉效果。尝试切换不同的光标字符来体验。' ,
235+ cursorChar: ' |' ,
199236 };
200237 },
201238 methods: {
248285 />
249286
250287 <div class =" demo-controls" >
251- <el-button size =" small" type =" primary" @click =" startFogDemo"
252- >预览</el-button
288+ <el-button
289+ size =" small"
290+ type =" primary"
291+ @click =" startFogDemo"
253292 >
293+ 预览
294+ </el-button >
254295 </div >
255296 </div >
256297</template >
260301 data () {
261302 return {
262303 fogContent:
263- " 雾化效果可以增强打字过程的视觉体验,通过调整雾化宽度和背景色来匹配不同的设计风格。" ,
304+ ' 雾化效果可以增强打字过程的视觉体验,通过调整雾化宽度和背景色来匹配不同的设计风格。' ,
264305 fogWidth: 80 ,
265306 fogConfig: {
266- bgColor: " #FFFFFF" ,
267- width: " 80px" ,
307+ bgColor: ' #FFFFFF' ,
308+ width: ' 80px' ,
268309 },
269310 };
270311 },
299340 />
300341
301342 <div class =" demo-controls" >
302- <el-button size =" small" type =" primary" @click =" startMarkdownDemo"
303- >预览</el-button
343+ <el-button
344+ size =" small"
345+ type =" primary"
346+ @click =" startMarkdownDemo"
304347 >
348+ 预览
349+ </el-button >
305350 </div >
306351 </div >
307352</template >
@@ -358,30 +403,44 @@ console.log(greet('World'));
358403 />
359404
360405 <div class =" progress-bar" >
361- <el-progress :percentage =" progress" :show-text =" false" ></el-progress >
406+ <el-progress
407+ :percentage =" progress"
408+ :show-text =" false"
409+ ></el-progress >
362410 <div class =" progress-text" >{{ Math.floor(progress) }}%</div >
363411 </div >
364412
365413 <div class =" demo-controls" >
366414 <el-button-group >
367- <el-button size =" small" type =" primary" @click =" startControl"
368- >开始</el-button
415+ <el-button
416+ size =" small"
417+ type =" primary"
418+ @click =" startControl"
369419 >
420+ 开始
421+ </el-button >
370422 <el-button
371423 size =" small"
372424 type =" warning"
373425 :disabled =" !isTyping || progress >= 100"
374426 @click =" pauseControl"
375- >暂停</el-button
376427 >
428+ 暂停
429+ </el-button >
377430 <el-button
378431 size =" small"
379432 type =" success"
380433 :disabled =" isTyping || progress >= 100"
381434 @click =" continueControl"
382- >继续</el-button
383435 >
384- <el-button size =" small" @click =" resetControl" >重置</el-button >
436+ 继续
437+ </el-button >
438+ <el-button
439+ size =" small"
440+ @click =" resetControl"
441+ >
442+ 重置
443+ </el-button >
385444 </el-button-group >
386445 </div >
387446 </div >
@@ -392,7 +451,7 @@ console.log(greet('World'));
392451 data () {
393452 return {
394453 controlContent:
395- " 这个示例展示了如何控制打字过程,包括开始、暂停、继续和重置功能。你可以通过下方的按钮来体验这些控制功能。" ,
454+ ' 这个示例展示了如何控制打字过程,包括开始、暂停、继续和重置功能。你可以通过下方的按钮来体验这些控制功能。' ,
396455 isTyping: false ,
397456 progress: 0 ,
398457 };
@@ -471,9 +530,12 @@ console.log(greet('World'));
471530 </div >
472531
473532 <div class =" demo-controls" >
474- <el-button type =" primary" @click =" regenerateResponse"
475- >重新生成回答</el-button
533+ <el-button
534+ type =" primary"
535+ @click =" regenerateResponse"
476536 >
537+ 重新生成回答
538+ </el-button >
477539 </div >
478540 </div >
479541</template >
@@ -483,7 +545,7 @@ console.log(greet('World'));
483545 data () {
484546 return {
485547 aiResponse:
486- " Typewriter组件是一个模拟打字效果的UI组件,支持自定义打字速度、步长和光标样式。它可以用于展示AI生成内容、代码示例或任何需要逐步显示的场景。\n\n 该组件还支持Markdown渲染和代码高亮,以及光标雾化效果,使得内容展示更加生动有趣。" ,
548+ ' Typewriter组件是一个模拟打字效果的UI组件,支持自定义打字速度、步长和光标样式。它可以用于展示AI生成内容、代码示例或任何需要逐步显示的场景。\n\n 该组件还支持Markdown渲染和代码高亮,以及光标雾化效果,使得内容展示更加生动有趣。' ,
487549 };
488550 },
489551 methods: {
@@ -596,9 +658,13 @@ console.log(greet('World'));
596658 </div >
597659
598660 <div class =" demo-controls" >
599- <el-button size =" small" type =" primary" @click =" startComplete"
600- >预览</el-button
661+ <el-button
662+ size =" small"
663+ type =" primary"
664+ @click =" startComplete"
601665 >
666+ 预览
667+ </el-button >
602668 </div >
603669 </div >
604670</template >
@@ -624,13 +690,13 @@ function demo() {
624690 },
625691 methods: {
626692 handleStart () {
627- console .log (" 打字开始" );
693+ console .log (' 打字开始' );
628694 },
629695 handleTyping ({ progress }) {
630696 this .progress = progress;
631697 },
632698 handleFinish (instance ) {
633- console .log (" 打字完成" , instance);
699+ console .log (' 打字完成' , instance);
634700 },
635701 startComplete () {
636702 this .$refs .completeDemo .restart ();
0 commit comments