Ionic Framework - HTML rel import works on emulator but NOT on device

荒凉一梦 提交于 2019-12-23 01:02:21

问题


I am trying to import the contents (import the reference of the CSS and JavaScript files) of a particular html page, named "helper.html" to another html page,named "navigation.html". It works on the emulator (the reference of the CSS and JavaScript files of the "helper.html" can be imported) but NOT on the device (the device I am using is Android tablet).

My project directory looks like this:

www

-templates

  • navigation.html (inside templates folder)

-helper.html (inside www)

In my "navigation.html", I have the following code snippet:

<!DOCTYPE html>
<html>
<head>
<link rel="import" href="helper.html">
</head>
<body>
 <ion-view view-title="Navigation">
    <ion-content>
  // SOME CODES
 </ion-content>
    </ion-view>

 </body>
 </html>

In my "helper.html", I have the following code snippet:

<!DOCTYPE html>
<html>
<head>
 <title></title>
<link rel="stylesheet" href="css/pathFindingstyle.css" />
  <!-- Some JS files to be loaded, but I am not posting them here-->
 </head>
<body >
 <div id="draw_area"></div>
 <div id="stats"></div>
</body>
</html>

Can someone tell me a way how I could make this work on the android device? Thanks!


回答1:


Old versions of Cordova for Android (<= 4.4.4) don't use Blink, the Chromium / Chrome web engine, or use an old version of Blink (< 36) that doesn't implement Web Components -including HTML Imports- for HTML rendering.

Therefore you'll need to upgrade Android to version 5+, or to use a more recent device to get a native implementation.

As a workaround, you can try to use the webcomponentsjs polyfill, with the HTMLImports.js file which emulates HTML Imports (though I don't know if it will work on your Android version).



来源:https://stackoverflow.com/questions/41539717/ionic-framework-html-rel-import-works-on-emulator-but-not-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!