3136352472 5 years ago
parent
commit
b3864e8ecd
  1. 5
      jsruntime/timeout.go
  2. 1
      static/use.js

5
jsruntime/timeout.go

@ -3,7 +3,6 @@ package jsruntime
import (
"github.com/dop251/goja"
"log"
"time"
)
func (jr *JsRuntime) EnableTimeoutFunc() {
@ -11,13 +10,13 @@ func (jr *JsRuntime) EnableTimeoutFunc() {
jr.runtime.Set("setTimeout", func(call goja.FunctionCall) goja.Value {
if fn, ok := goja.AssertFunction(call.Argument(0)); ok {
delay := call.Argument(1).ToInteger()
//delay := call.Argument(1).ToInteger()
var args []goja.Value
if len(call.Arguments) > 2 {
args = call.Arguments[2:]
}
//
time.Sleep(time.Duration(delay) * time.Millisecond)
//time.Sleep(time.Duration(delay) * time.Millisecond)
fn(nil, args...)
}

1
static/use.js

@ -25,6 +25,5 @@ GoUseRegistered("index", function (query) {
"a": "官方ssr模式",
"descs":["123","456"]
},
});
});
Loading…
Cancel
Save