Angular 角度通用设置超时

Angular 角度通用设置超时,angular,server-side-rendering,angular-universal,Angular,Server Side Rendering,Angular Universal,我知道Settimeout不能与angular universal一起使用,但是否有替代方案 typingCallback(that, text, a, direction) { if (text.length > 0) { let total_length = text.length; let current_length = that.typewriter_display.length; if (direction == "forw

我知道
Settimeout
不能与angular universal一起使用,但是否有替代方案

typingCallback(that, text, a, direction) {
    if (text.length > 0) {
      let total_length = text.length;
      let current_length = that.typewriter_display.length;
      if (direction == "forward") {
        if (current_length < total_length) {
          that.typewriter_display += text[current_length];
          setTimeout(that.typingCallback, 200, that, text, a, "forward");
        } else {
          //Trigger Remove

          setTimeout(that.typingCallback, 500, that, text, a, "backward");
        }
      } else {
        //Remove 
        if (current_length >= total_length && current_length != 1) {
          var pos = text.lastIndexOf(text[current_length-1]);
          text = text.substring(0,pos) + '' + text.substring(pos+1)
          that.typewriter_display = text;
          setTimeout(that.typingCallback,50,that,text,a,"backward");
        } else {
          //Text Removed send forward
          that.typewriter_display = "";
          if (a < (that.dataText.length-1)) {
            a++;
            setTimeout(function() {
              that.typingCallback(that, that.dataText[a], a,"forward");
            },300)
          } else {
            a = 0;
            setTimeout(function() {
              that.typingCallback(that, that.dataText[a], a,"forward"); 
            }, 200)
          }
        }
      }
    }
    }
键入回调(即,文本,a,方向){
如果(text.length>0){
总长度=text.length;
让current_length=that.typewriter_display.length;
如果(方向=“前进”){
if(当前长度<总长度){
打字机显示+=文本[当前长度];
setTimeout(that.typingCallback,200,that,text,a,“forward”);
}否则{
//扳机拆除
setTimeout(that.typingCallback,500,that,text,a,“backward”);
}
}否则{
//除去
如果(当前长度>=总长度和当前长度!=1){
var pos=text.lastIndexOf(text[current_length-1]);
text=text.substring(0,位置)+''+text.substring(位置+1)
打字机显示=文本;
setTimeout(that.typingCallback,50,that,text,a,“backward”);
}否则{
//已删除的文本转发
那个。打字机_display=“”;
如果(a<(即.dataText.length-1)){
a++;
setTimeout(函数(){
that.typingCallback(that,that.dataText[a],a,“forward”);
},300)
}否则{
a=0;
setTimeout(函数(){
that.typingCallback(that,that.dataText[a],a,“forward”);
}, 200)
}
}
}
}
}

上面的函数显示给定的文本,然后在写入另一个文本之前将其删除。我想知道是否有设置超时的替代方法,以便我的网站中仍然可以使用上述功能。

这是否有帮助?SetTimeout确实适用于angular universal,只是它会减慢渲染速度。什么时候调用该函数?它是一个自定义函数这可能有帮助吗?SetTimeout确实适用于angular universal,只是它会减慢渲染速度。什么时候调用该函数?它是一个自定义函数