autotypejs
use for typing automatically.
介绍
使用原生JavaScript(es6)实现的自动打字效果。
效果图
示例代码(vue):
<template>
<div class="type-container"></div>
</template>
<script>
import AutoType from "autotypejs";
export default {
name: "AutoType",
mounted() {
const autoType = new AutoType(".type-container");
autoType.config({
loop: false,
show_cursor: true,
});
autoType
.setStage({
type: "add",
text: "如梦今",
duration: 1000,
style: {
"font-weight": "bold",
"font-size": "23px",
},
})
.setStage({
type: "delete",
delete_count: 1,
duration: 300,
})
.setStage({
text: "令",
duration: 300,
style: {
"font-weight": "bold",
"font-size": "23px",
},