文字的打字机效果是否是感受蛮炫呢,实际上是用typed.js这个插件实现的哦~web
With NPM
npm install typed.js
npm
With Yarn
yarn add typed.js
hexo
With Bower
bower install typed.js
svg
详细内容戳 👉 typed.js官网oop
使用很是简单,在相对应的页面中加入如下代码就完成啦。插件
<script src="<%- theme.libs.js.typed %>"></script> //引入js文件 <script> var options = { strings: [' <%- config.description %>', ' <%- config.descriptionEN %>'], typeSpeed: 120, //打印的速度。数值越大,速度越慢 loop: true, //开启循环 loopCount: Infinity, //设置循环次数,值为:Infinity,也能够使用数值 backSpeed: 20, //延迟时间后才后退,值越大,延迟的时间就越长 cursorChar: '^' //光标的符号,好比: }; var typed = new Typed('#description', options); </script>
代码中引入的src为
<%- theme.libs.js.typed %>
变量,是由于我用的主题hexo-theme-matery
中js
文件都是统一管理的,为了保持一致,我将npm i
后的typed.min.js
文件单独放在了theme的source/libs
目录下,
并在theme
的_config.yml
添加了libs的对应目录配置。code
❤
若是光标改为表情会更赞哦~xml
若是这篇文章对你有帮助或是喜欢的话,能够戳下方对小举赏一个哟
😘
ip