报错:
Appid: UNIA4BB50E
e: file://[PackagePath]/wgtRoot/UNIA4BB50E/uni_modules/ns-miniServer/utssdk/app-android/src/index.kt:32:95 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun Number.plus(other: Number): Number defined in io.dcloud.uts
public operator fun Number.plus(other: String): String defined in io.dcloud.uts
e: file://[PackagePath]/wgtRoot/UNIA4BB50E/uni_modules/ns-miniServer/utssdk/app-android/src/index.kt:34:90 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun Number.plus(other: Number): Number defined in io.dcloud.uts
public operator fun Number.plus(other: String): String defined in io.dcloud.uts
FAILURE: Build failed with an exception.
-
What went wrong:
Execution failed for task ':uni_modules:ns-miniServer:compileReleaseKotlin'.A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details -
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights. -
Get more help at https://help.gradle.org
BUILD FAILED in 1m 26s
Error code = -5000
Error message:
UTS plugin @ uni_modules ns-miniServer compile error!
import { UTSAndroid } from "io.dcloud.uts";
import JsCallback from "com.example.miniserver.JsCallback"
import MiniServer from "com.example.miniserver.MiniServer"
import File from "java.io.File"
type opt = {
msg : string,
port : number,
onSaved : (result : string,time:string) => void;
}
export class Server {
private server : MiniServer;
constructor(options :opt ) {
class OtherCallback implements JsCallback {
public override onEnd(result : string, time: string):void {
options.onSaved(result,time)
}
}
this.server = new MiniServer();
this.server.get("/", UTSAndroid.getResourcePath("uni_modules/ns-miniServer/static/index.html"))
this.server.post("/postBook", options.msg, UTSAndroid?.getAppContext()?.getCacheDir()+File.separator, new OtherCallback())
this.server.listen(4567)
console.log("/postBook", options.msg, UTSAndroid?.getAppContext()?.getCacheDir()+File.separator, new OtherCallback());
}
stop():void{
this.server.stop()
}
}
代码:
2***@qq.com (作者)
晕了
2023-11-18 21:06