cordova script src 采用相对路径而不是绝对路径
cordova script src takes relative path rather absolute
我正在用 cordova 构建一个混合应用程序。我的文件夹结构看起来像
www
- bower_components
- 组件
- 字体
- 脚本
- 样式
- 图片
index.html
当我使用 cordova 构建项目时 (cordova build) 以及当我 运行 cordova serve
javascripts 文件是从根路径提供的
Javascript 从相对路径获取而 css 完美加载
请帮我解决这个问题。但是当我 运行 来自 cordova 的演示项目时,这不是问题。
这是索引文件。它的缩小版
<!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("uiSidebarLeft")" ng-swipe-left="Ui.turnOff("uiSidebarLeft")"> <!-- 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>
`
问题不在于 cordova,因为我在 html 中为 angular js 添加了 BASE 标签,并且我设置了 <base href='/'>
.所以脚本采用绝对路径。
我正在用 cordova 构建一个混合应用程序。我的文件夹结构看起来像
www
- bower_components
- 组件
- 字体
- 脚本
- 样式
- 图片
index.html
当我使用 cordova 构建项目时 (cordova build) 以及当我 运行 cordova serve
javascripts 文件是从根路径提供的
请帮我解决这个问题。但是当我 运行 来自 cordova 的演示项目时,这不是问题。
这是索引文件。它的缩小版
<!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("uiSidebarLeft")" ng-swipe-left="Ui.turnOff("uiSidebarLeft")"> <!-- 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>
`
问题不在于 cordova,因为我在 html 中为 angular js 添加了 BASE 标签,并且我设置了 <base href='/'>
.所以脚本采用绝对路径。