grunt serve VS 在浏览器中打开 index.html
grunt serve VS opening index.html in browser
我正在使用 Yeoman 和 angular-fullstack 生成器来 bootstrap 一个 angular 应用程序。当我执行 grunt serve
或 grunt serve:dist
时,一切都按预期工作。
现在的问题是,当我直接在浏览器中打开 index.html 文件时,它不是应该同样有效吗?
所以我很难理解 g运行t 在这里执行什么任务才能让它工作。或者也许我还遗漏了其他东西。
控制台告诉我:
GET file:///app/8d57a97f.app.css net::ERR_FILE_NOT_FOUND
GET file:///app/47ab0f3e.vendor.js net::ERR_FILE_NOT_FOUND
GET file:///app/01b9b8a8.app.js net::ERR_FILE_NOT_FOUND
生成的 index.html 看起来像这样:
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="app/8d57a97f.app.css"/>
</head>
<body ng-app="myApp">
<!-- some functionality... -->
<script src="app/47ab0f3e.vendor.js"></script>
<script src="app/01b9b8a8.app.js"></script>
</body>
</html>
我这样做的原因:
我尝试在 android 设备上 运行 使用 phonegap 的 angular 应用程序。当我将它加载到 android 手机时,屏幕仍然空白。于是用浏览器打开,结果一样
所以这是我第一次尝试解决这个问题。
问题出在 header 中的 <base href="/">
。
可以在此处找到解释 (Loading local file in browser referenced css or js)。
我正在使用 Yeoman 和 angular-fullstack 生成器来 bootstrap 一个 angular 应用程序。当我执行 grunt serve
或 grunt serve:dist
时,一切都按预期工作。
现在的问题是,当我直接在浏览器中打开 index.html 文件时,它不是应该同样有效吗?
所以我很难理解 g运行t 在这里执行什么任务才能让它工作。或者也许我还遗漏了其他东西。
控制台告诉我:
GET file:///app/8d57a97f.app.css net::ERR_FILE_NOT_FOUND
GET file:///app/47ab0f3e.vendor.js net::ERR_FILE_NOT_FOUND
GET file:///app/01b9b8a8.app.js net::ERR_FILE_NOT_FOUND
生成的 index.html 看起来像这样:
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="app/8d57a97f.app.css"/>
</head>
<body ng-app="myApp">
<!-- some functionality... -->
<script src="app/47ab0f3e.vendor.js"></script>
<script src="app/01b9b8a8.app.js"></script>
</body>
</html>
我这样做的原因:
我尝试在 android 设备上 运行 使用 phonegap 的 angular 应用程序。当我将它加载到 android 手机时,屏幕仍然空白。于是用浏览器打开,结果一样
所以这是我第一次尝试解决这个问题。
问题出在 header 中的 <base href="/">
。
可以在此处找到解释 (Loading local file in browser referenced css or js)。