美文网首页
uniapp 文字跑马

uniapp 文字跑马

作者: 醉青风 | 来源:发表于2020-08-27 17:56 被阅读0次

    /**

    * 文字跑马 //第一个this  第二个为输入的文字, 第三个为赋值的字段  第4个是定时器

    * pms: {

    upTimer: '',//定时器

    text: '输入的文字输入的文字输入的文字输入的文字输入的文字输入的文字输入的文字',

    texts: '',//赋值的字段

    }

    传入数据为 (this.pms,this.pms.text,'texts','upTimer')

    */

    var typewriting = function(that, text, texts, upTimer) {

    clearInterval(that[upTimer])

    let index = 0

    that[texts] = ''

    that[upTimer] = setInterval(function() {

    if (that[texts].length < text.length) {

    that[texts] = that[texts] + text.substring(index, index + 1)

    index = index + 1

    } else {

    clearInterval(that[upTimer])

    }

    }, 100)

    }

    module.exports = {

    typewriting

    }

    相关文章

      网友评论

          本文标题:uniapp 文字跑马

          本文链接:https://www.haomeiwen.com/subject/blhhsktx.html