mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 12:49:29 +08:00
Added variadic workaround to troubleshooting guide
This commit is contained in:
parent
659cc3ed61
commit
3a23662a34
@ -24,4 +24,34 @@ If your built application looks like this in finder:
|
||||
|
||||
it's likely that your application's `info.plist` is invalid. Update the file in `build/<yourapp>.app/Contents/info.plist`
|
||||
and check if the data is valid, EG check the binary name is correct. To persist the changes, copy the file back to
|
||||
the `build/darwin` directory.
|
||||
the `build/darwin` directory.
|
||||
|
||||
## Cannot call backend method from frontend with variadic arguments
|
||||
|
||||
If you have a backend method defined with variadic parameters, eg:
|
||||
```go
|
||||
func (a *App) TestFunc(msg string, args ...interface{}) error {
|
||||
// Code
|
||||
}
|
||||
```
|
||||
calling this method from the frontend like this will fail:
|
||||
```js
|
||||
var msg = "Hello: "
|
||||
var args = ["Go", "JS"]
|
||||
window.go.main.App.TestFunc(msg, ...args).then((result) => {
|
||||
//do things here
|
||||
}).catch((error) => {
|
||||
//handle error
|
||||
});
|
||||
```
|
||||
Workaround:
|
||||
```js
|
||||
var msg = "Hello "
|
||||
var args = ["Go", "JS"]
|
||||
window.go.main.App.TestFunc(msg, args).then((result) => { //without the 3 dots
|
||||
//do things here
|
||||
}).catch((error) => {
|
||||
//handle error
|
||||
});
|
||||
```
|
||||
Credit: https://github.com/wailsapp/wails/issues/1186
|
Loading…
Reference in New Issue
Block a user