weex
weex copied to clipboard
【PR】请教下iOS 端 native怎么传值到js
iOS native本地需要传参数到js页面,请教下怎么操作。
@voidxin 可以自定义module ,在callBack里面 返回到js
可以参考 doc 扩展
@acton393 ok,谢了
@acton393 请问这里回调之后的function只能执行或调用native的方法吗?(iOS端)
var eventModule = require('@weex-module/event');
eventModule.openURL('url',function(ret) {
//这里只能执行native的方法吗?
nativeLog(ret);
});
我在js中使用本js中的方法时它不执行(如下):
var eventModule = require('@weex-module/event');
eventModule.openURL('url',function(ret) {
//这是本js中的一个方法,不执行test()方法
this.test();
//当我换成native的一个方法时,如下的updateVersionWithStr(),能调用执行
eventModule.updateVersionWithStr(result);
});
//js中的test方法
test: function() {
//TODO SOMETHING
},
请问回调之后的function只能执行或调用native的方法吗? 我该怎么做?
ok,我发现问题了,作用域的问题,要在外部先申明var self = this;
var self = this
eventModule.openURL(''url", function(ret){
self.test()
})
这样就可以了。
@voidxin http://openmymind.net/2012/2/3/Node-Require-and-Exports/ 可以参考下这里看下
原生界面直接跳转weex界面,同时需要传递参数过去,有什么方法吗? 这里的解决方案 仅适用于 在weex界面调用原生模块,原生再返回给weex数据