https://blog.csdn.net/qq_41993503/article/details/107640238
<p class='typewriter'>{{typewriter}}</p>
data () {
return {
typewriter: '',
i: 0,
timer: 0,
str: 'Hi, i´m a web Designer'
}
}
mounted () {
this.typeing()
},
methods: {
typeing () {
if (this.i <= this.str.length) {
this.typewriter = this.str.slice(0, this.i++) + '_'
this.timer = setTimeout(() => {
this.typeing()
}, 150)
} else {
clearTimeout(this.timer)
}
}
}