跳到主要内容
版本:下个版本 🚧

故障排除

各种故障排除技巧。

我的应用程序显示白色/空白屏幕

If your system is reporting that the wails command is missing, make sure you have followed the Go installation guide correctly. Normally, it means that the go/bin directory in your User's home directory is not in the PATH environment variable. You will also normally need to close and reopen any open command prompts so that changes to the environment made by the installer are reflected at the command prompt.

Mac 应用程序无效

检查您的应用程序是否在正确目录中包含资源。 在您的main.go文件中,您将拥有类似于以下代码的内容:

//go:embed frontend/dist
var assets embed.FS

如果您构建的应用程序在 finder 中如下所示:

Mac

If this happens on Mac, try adding the following to your Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>

Reference: https://github.com/wailsapp/wails/issues/1504#issuecomment-1174317433

前端调用后端方法无法使用可变参数

如果您有使用可变参数定义的后端方法,例如:

您的应用程序的 info.plist 可能无效。 更新 build/<yourapp>.app/Contents/info.plist 文件并检查数据是否有效,例如二进制文件名称是否正确。 要保留更改,请将文件复制回 build/darwin 目录。

尝试安装 Wails 时遇到代理错误

归功于:https://github.com/wailsapp/wails/issues/1186

func (a *App) TestFunc(msg string, args ...interface{}) error {
// Code
}

如果您遇到这样的错误:

var msg = "Hello ";
var args = ["Go", "JS"];
window.go.main.App.TestFunc(msg, args)
.then((result) => {
// 不需要展开符
// do things here
})
.catch((error) => {
//handle error
});

解决办法:

var msg = "Hello: ";
var args = ["Go", "JS"];
window.go.main.App.TestFunc(msg, ...args)
.then((result) => {
//do things here
})
.catch((error) => {
//handle error
});

来源:https://github.com/wailsapp/wails/issues/1233

I''m having getting proxy errors when trying to install Wails

If you are getting errors like this:

"https://proxy.golang.org/github.com/wailsapp/wails/cmd/wails/@v/list": dial tcp 172.217.163.49:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

这可能是因为官方 Go Proxy 被阻止(中国用户反馈了这一点)。 解决方案是手动设置代理,例如:

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

Source: https://github.com/wailsapp/wails/issues/1233

The generated Typescript doesn''t have the correct types

Sometimes the generated Typescript doesn''t have the correct types. Sometimes the generated Typescript doesn''t have the correct types. To mitigate this, it is possible to specify what types should be generated using the ts_type struct tag. For more details, please read this. For more details, please read this. Sometimes the generated Typescript doesn''t have the correct types. To mitigate this, it is possible to specify what types should be generated using the ts_type struct tag. For more details, please read this. For more details, please read this.

检查frontend/dist中是否包含您的应用程序资源。

If you navigate away from index.html to a new html file, the context will be lost. If you navigate away from index.html to a new html file, the context will be lost. This can be fixed by adding the following imports to the <head> section of any new page you navigate to: If you navigate away from index.html to a new html file, the context will be lost. This can be fixed by adding the following imports to the <head> section of any new page you navigate to:

<head>
<script src="/wails/ipc.js"></script>
<script src="/wails/runtime.js"></script>
</head>

Source: https://github.com/wailsapp/wails/discussions/1512