Golang 使用 Lorca 错误信息:
websocket.Dial ws://127.0.0.1:51233/devtools/browser/0bfe6d19-b953-4b32-8fed-7a569d2d01cb: 状态错误
退出状态 1
package main
import (
"log"
"net/url"
"github.com/zserge/lorca"
)
func main() {
// 通过数据URI传递基本HTML创建UI
ui, err := lorca.New("data:text/html,"+url.PathEscape(`
<html>
<head><title>Hello</title></head>
<body><h1>Hello, world!</h1></body>
</html>
`), "", 480, 320, "--remote-allow-origins=*")
if err != nil {
log.Fatal(err)
}
defer ui.Close()
// 等待UI窗口关闭
<-ui.Done()
}
参考https://github.com/zserge/lorca/issues/183#issuecomment-1460603663 修改为:
package main
import (
"log"
"net/url"
"github.com/zserge/lorca"
)
func main() {
// 通过数据URI传递基本HTML创建UI
ui, err := lorca.New("data:text/html,"+url.PathEscape(`
<html>
<head><title>Hello</title></head>
<body><h1>Hello, world!</h1></body>
</html>
`), "", 480, 320, "--remote-allow-origins=*")
if err != nil {
log.Fatal(err)
}
defer ui.Close()
// 等待UI窗口关闭
<-ui.Done()
}