简体   繁体   中英

cordova script src takes relative path rather absolute

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> 

`

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.

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