我正在制作一个AngularJS + AngularFire + Firebase应用程序。 我的问题与此帖(check post)
中的描述相同但解决方案没有帮助我。 我的firebase json设置如下
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
我正在尝试处理浏览器刷新,这就是我将目标设置为index.html的原因,我已在此链接上的firebase上部署了我的应用https://blinding-fire-7418.firebaseapp.com/
当我点击GotoHome然后打开新页面然后我点击浏览器刷新按钮它会产生错误。
实际上,当我浏览器刷新时,firebase
无法找到指定的网址,因此firebase
会将网址重写为index.html,同时再次加载index.html时会出现以下错误,angular.min.js
的内容会被替换为index.html的内容。
angular.min.js:1 Uncaught SyntaxError: Unexpected token <
angular-route.min.js:1 Uncaught SyntaxError: Unexpected token <
angularfire.min.js:12 Uncaught ReferenceError: angular is not defined(anonymous function) @ angularfire.min.js:12(anonymous function) @ angularfire.min.js:12
App.js:1 Uncaught SyntaxError: Unexpected token <
这是index.html代码:
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app="sampleApp">
<head>
<title>My new Project</title>
<meta charset="utf-8" />
<!-- AngularJS -->
<script type="text/javascript" src="/Scripts/angular.min.js"></script>
<script type="text/javascript" src="/Scripts/angular-route.min.js"></script>
<script type="text/javascript" src="/Scripts/App.js"></script>
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
</head>
<body ng-view>
</body>
</html>