-
设置一个html容器,一般使用pre标签作为容器,将打印字符放置到其中
<pre> function main() { <div class="codetypewriter"></div> } </pre>
-
引入CodeTypewriter.js文件,导入该文件后将会获得一个构造函数CodeTypewriter
new CodeTypewriter({ element: document.querySelector(".codetypewriter"),//html容器 data: "\tcout << \"Hello World\";\n\treturn 0;",//内容字符串 animation: "lineFeed", //动画样式line | both | lineFeed cursor: "vertical" //光标样式 transverse | vertical time: 200 // 打印每个字符的时间 }).init();
-
使用new关键字构造一个对象并调用init方法即可
-
Notifications
You must be signed in to change notification settings - Fork 0
queuecat/CodeTypewriter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
一个逐行打印字符的js方法
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published