简体   繁体   中英

JavascriptInterface cannot be called in H5

I used vue to write an h5 page embedded in the app. The page and app use window.JSInterface to communicate. I need to call JSInterface(javascriptinterface) to access the getResString method in Android to get user information, but now JSinterface is not called or the call fails. As a result, I cannot access any method that Android mounts to JSInterface .

The Android programmer told me that H5 didn't call any methods, and I didn't have his code here. He told me exactly that there would be no problem with the code on the Android side. It must be my problem.

More importantly, because the problem was JSInterface , I couldn't debug it and couldn't start.

Below is the code that I call the JSInterface part, please see how I should do it. thank you all.

if (window.JSInterface) {
      this.test.push(1);     //test:[1]
      this.token = window.JSInterface.getResString("TOKEN");
      this.test.push(2);    //test:[1]
      this.appid = window.JSInterface.getResString("APP_ID");
      this.info_id.userid = window.JSInterface.getResString("USER_ID");
      this.info_id.device_id = window.JSInterface.getResString("DEVICE_ID");
      this.$i18n.locale = window.JSInterface.getResString("SYSTEM_LA");
    }
    this.test.push(3)     // test:[1]


goNativePage(val) {
          if (window.JSInterface) {
            //also can not be called 
            window.JSInterface.toNativePage(val, "");
          }

console report a error : Type error : window.JSInterface.getResString is not a function

Andriod家伙的错,他混淆了依赖库

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM