cordova script src takes relative path rather absolute

让人想犯罪 __ 提交于 2019-12-25 03:27:33

问题


I am building a hybrid app out of cordova . my folder structure looks like


www

  • bower_components
  • components
  • fonts
  • scripts
  • styles
  • images

index.html


When i build the project using cordova (cordova build) and when i run cordova serve the javascripts files are served from root path

Javascript takes from relative path whereas the css are loaded perfectly

Please help me in solving this is issue. but this is not problem when i run demo project from cordova .

this is index file. its in minified version

<!doctype html> <html class="no-js"> <head> <meta charset="utf-8"> <title>KnoTalk</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.460a10c2.css"> <link rel="stylesheet" href="styles/main.b59cb9a9.css"> <link rel="shortcut icon" type="image/png" href="images/favicon.fcf321eb.png"> <base href="/">  <body ng-app="knotalk"> <div class="sidebar sidebar-left"> <div ng-include="'components/sidebar/sidebar.html'"></div> </div> <div class="sidebar sidebar-right"> <div ng-controller="MainController"> <div ng-if="isChannel"> <div ng-include="'components/middleSection/channelMetaInfo.html'"></div> </div> <div ng-if="!isChannel"> <div ng-include="'components/middleSection/userMetaInfo.html'"></div> </div> </div> </div> <div class="app" ng-swipe-right="Ui.turnOn(&quot;uiSidebarLeft&quot;)" ng-swipe-left="Ui.turnOff(&quot;uiSidebarLeft&quot;)"> <!-- Add your site or application content here --> <!-- angular spinner --> <span us-spinner spinner-key="spinner-1"></span> <div ng-include="src='components/header/header.html'"></div> <div class="app-body"> <div class="app-content"> <div ng-view=""></div> </div> </div> </div> <div ui-yield-to="modals"></div> <!--[if lt IE 9]>
    <script src="scripts/oldieshim.fa8ddb71.js"></script>
    <![endif]--> <script type="text/javascript" src="cordova.js"></script><script type="text/javascript" href="scripts/vendor.1a204611.js"></script> <script href="scripts/scripts.79913f18.js" type="text/javascript"></script>  

`


回答1:


The problem was not with cordova its because i have added BASE tag in html for for angular js and i have set <base href='/'>. So the scripts takes absolute path.



来源:https://stackoverflow.com/questions/28297908/cordova-script-src-takes-relative-path-rather-absolute

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