2016-12-06 104 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之前,瀏覽器視圖需要加載。