100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > JS 封装打字机效果方法 vue

JS 封装打字机效果方法 vue

时间:2021-03-06 16:54:02

相关推荐

JS 封装打字机效果方法 vue

// 打字机效果typewriter(txt, index) {this.$refs.nowReply.innerHTML = ''let timer = setInterval(() => {this.$refs.nowReply.innerHTML += txt.substring(index, index + 1)index++;if (index >= txt.length) {clearInterval(timer);timer = '';this.showReply = false;this.$refs.nowReply.innerHTML = ''this.pushbotmsg(txt)}if (index % 5 === 0) {this.scrollPage()}}, 50)},

txt:需要打字的文本

index:一般为0,从问问头部开始打印

this.$refs.nowReply:显示文本的div框

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。