2016-12-06 101 views
1

在我的应用程序中,我试图执行一些使用InAppBrowser的executeScript方法的脚本。记住我使用的是Ionic Framework v2,这是我的代码:方法'executeScript'不工作 - InAppBrowser

browser.executeScript({ 
      code: ` 
       $(".rodape.geral table tbody tr:nth-child(2) td:nth-child(1) div:nth-child(1)").css("min-width","auto"); 
       $(".rodape.geral table tbody tr:nth-child(2) td:nth-child(1) div:nth-child(1) div:nth-child(1)").css("width","auto"); 
       $(".rodape.geral table tbody tr:nth-child(1) td:nth-child(2) table:nth-child(1)").attr("align","center"); 
      ` 
      }).then((e)=>{ console.log('JS adicionado.'); }).catch((e)=>{ console.log('Erro ao adicionar JS. '+e); }); 

为什么代码不起作用,没有返回回调? THKS。

回答

0

确保此代码位于inAppBrowser的loadstop事件侦听器中。

在运行JS之前,浏览器视图需要加载。