每当我尝试从一个网址导航到navigation dropdown bar
中存在的其他网址时,我都会收到此错误。它显示了jquery错误。但是当我放在html页面的其他地方时,它会正确导航。
Uncaught Error: Syntax error, unrecognized expression: #/details/
由于这条线,我遇到冲突如何解决它
$(".navbar a, footer a[href='#myPage']").on('click', function(event) {
event.preventDefault();
var hash = this.hash;
if(hash.length > 1){
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 'slow');
}
});
并且在索引文件中这是代码
<link rel="stylesheet" type="text/css" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/node_modules/angular/angular.min.js"></script>
<!-- <script type="text/javascript" src="./assets/js/lib/parallax.min.js"></script> -->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript" src="https://rawgit.com/pablojim/highcharts-ng/master/src/highcharts-ng.js"></script>
<script type="text/javascript" src="/node_modules/angular-route/angular-route.min.js"></script>
在controller.js中,这是代码
app.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/home-folder/main.html',
controller: 'MainCtrl'
}).
when('/details', {
templateUrl: 'partials/details-folder/detail.html',
controller: 'DetailCtrl'
}).
otherwise({
redirectTo: '/'
});
从html我想调用详细信息页面但是我得到了上面的错误...他们都没有从下面的例子开始工作
<a href="#/details/">test1</a>
<a href="#/details">test2</a>
<a href="/details/">test3</a>
<a href="/details">test4</a>