vue3项目使用TypeIt打字机

编程入门 行业动态 更新时间:2024-10-11 17:23:35

vue3项目使用TypeIt<a href=https://www.elefans.com/category/jswz/34/1699639.html style=打字机"/>

vue3项目使用TypeIt打字机

官网: TypeIt | The most versatile JavaScript typewriter effect library on the planet.

下载: npm i typeit 

使用方法:

正常打字

多行打字机

input输入框实现打字机效果

打字机颜色变化

删除,光标移动,最全面的打字机效果

官网最下面还可以输入你想有的打字效果,然后生成代码

录屏2023-10-23 14.27.03

实际炫酷效果展示:

录屏2023-10-23 14.32.44

代码:

<script setup>
import { ref, reactive, onMounted } from 'vue'
onMounted(()=>{new TypeIt("#simpleUsage", {strings: ["This is a simple string.","This is a simple stringasdf","This is a simple stringasdfafs"],speed: 50,waitUntilVisible: true,}).go();
})
import TypeIt from 'typeit'
</script><template><div><span>这里是typewriter</span><p id="simpleUsage"></p></div>
</template><style scoped lang='less'></style>
<template><span ref="text" class="msg"></span>
</template><script setup>
// 
// npm install typeit
import { ref, onMounted } from "vue";
import TypeIt from 'typeit'
const text = ref(null)
onMounted(() => {new (TypeIt)(text.value, {strings: ["你好", "欢迎", "测试测试测试"],cursorChar: "<span class='cursorChar'>|<span>",//用于光标的字符。HTML也可以speed: 100,lifeLike: true,// 使打字速度不规则cursor: true,//在字符串末尾显示闪烁的光标breakLines: false,// 控制是将多个字符串打印在彼此之上,还是删除这些字符串并相互替换loop: true,//是否循环}).go()
})
</script><style scoped>
.msg {color: rgb(88, 88, 88);letter-spacing: 2px;
}.msg ::v-deep .cursorChar {display: inline-block;margin-left: 2px;
}
</style>

更多推荐

vue3项目使用TypeIt打字机

本文发布于:2023-12-04 03:58:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1659686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:打字机   项目   TypeIt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!