我刚刚开始学习Ionic,最近我添加了jquery
和angular-ui-router
到npm
,它在node_modules
文件夹中工作得很好。但是,当我启动我的应用程序并尝试包含这些文件时,它们不包括在内。在控制台中,错误为404 not found
。我已经检查了路径,但它根本不起作用。可能是因为node_modules
文件夹位于www
文件夹之外。我正在分享一张图片请告诉我什么是错的。
这是我的index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"></meta>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"></meta>
<title></title>
<link rel="manifest" href="manifest.json"></link>
<!-- un-comment this code to enable service worker
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then(() => console.log('service worker installed'))
.catch(err => console.log('Error', err));
}
</script> -->
<link href="lib/ionic/css/ionic.css" rel="stylesheet"></link>
<link href="asset_files/css/style.css" rel="stylesheet"></link>
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet"> -->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
</head>
<body ng-app="starter">
<div class="bar bar-header bar-positive">
<h1 class="title">Cleaners</h1>
</div>
<ion-content class="has-header" ui-view>
</ion-content>
<div class="bar bar-footer bar-balanced"></div>
<script>
document.write("<script type='text/javascript' src='require.js'><\/script>");
</script>
</body>
</html>
这是我的require.js
。
document.write("\
<script type='text/javascript' src='../node_modules/jquery/dist/jquery.min.js'><\/script>\
<script type='text/javascript' src='../node_modules/angular-ui-router/release/angular-ui-router.min.js'><\/script>\
<script type='text/javascript' src='app.js'><\/script>\
<script type='text/javascript' src='asset_files/js/routes.js'><\/script>\
");
我无法理解什么是错的。在控制台,网络中出现错误的路径是http://localhost:8100/node_modules/angular-ui-router/release/angular-ui-router.min.js