1.Vue和原生(ios和安卓)的交互(第一种方法)
一、原生调用Vue方法
1、Vue
created() {
window.getDataFromNative = this.getDataFromNative;
},
methods: {
getDataFromNative(params) {
console.log("得到原生传值结果:" + params);
var dic = {
'name': "vicky"
};
return dic;
},
}
2、原生
安卓
String toVueSting = "vickylizy";
webView.loadUrl("javascript:getDataFromNative('"+toVueSting+"')");
or:
webView.evaluateJavascript("javascript:getDataFromNative('" + toVueSting + "')", new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {