/**Laya ios*/
if(Laya.Browser.window.conch && Laya.Browser.onIOS){
let bridge = PlatformClass.createClass("JSBridge"); //脚本代理,参数直接传脚本名字
bridge.call("setTips:", ["111", "222"]); //带参数
bridge.call("setTips"); //不带参数
}
/**Laya android android带参和ios不同,注意:*/
if(Laya.Browser.window.conch && Laya.Browser.onAndroid){
//需要完整的脚本路径,注意与iOS的不同 dome的路径可在androidstudio查看
bridge = PlatformClass.createClass("demo.JSBridge");//创建脚步代理
call("setTips", ["111", "222"]); //带参数
call("setTips"); //不带参数
}
/**ios调用Laya脚本 和在Laya中的调用一样的*/
[[conchRuntime GetIOSConchRuntime] runJS:@"alert('hello world')"];
/**android调用Laya脚本 和在Laya的的调用一样 */
ConchJNI.RunJS("alert('hello world')");
LayaNative原生服务-二次开发
于 2023-09-13 01:29:18 首次发布