未捕获错误:语法错误,无法识别的表达式:#/ angularjs和jquery

每当我的页面加载时,我的控制台中都会显示以下错误

“未捕获的错误:语法错误,无法识别的表达式:#/ about”

我的代码如下:

  • Home
  • About
  • Pricing
  • 它显示了所有初始实例。 最初,它显示为#/ about,因为它是第一个,如果我删除关于我们选项卡它将显示定价页面链接。

    它不是引导标签问题,这只是简单的导航

    app.js中的路由代码:

     $routeProvider.when('/', { templateUrl: 'partials/home.html' }).when('/account', { templateUrl: 'partials/account.html', }).when('/terms', { templateUrl: 'partials/terms.html' }).when('/about', { templateUrl: 'partials/about.html' }).otherwise({ redirectTo: '/' }); 

    我已经调试了它的bootstrap,bootstrap nav导致这个问题的问题:“nav navbar-nav”修复了这个是data-target =“#”但是想要正确解决这个问题

    这很可能是一个Bootstrap问题。 尝试在链接上使用data-target属性

     About 

    好的,你必须删除你的html变成的斜杠’ / ‘,

     About 

    如果你想保留斜杠,’ / ‘你必须使用data-target属性,

     About 

    更多关于它的信息

    这个问题也发生在角度2项目上。 我只是将data-target =“#”添加到锚链接。 它解决了我的问题。

    这可能是一种非常罕见的情况,但由于使用Colorbox和location.hash的一些遗留代码,我遇到了同样的错误。

     jQuery(function() {jQuery('.content-row .csc-default a').tooltip({placement:'top'}); jQuery('a.gallery').colorbox({ maxWidth:'95%', maxHeight:'95%', slideshow:true, current:' {current} / {total}', opacity:'0.80', transition:'none', speed:'550', slideshowSpeed:'5500', overlayClose:true, fixed:false, escKey:true, arrowKey:true, loop:true, title: function() { return $(this).data('original-title')}, close:'', previous:'', next:'', slideshowStart:'', slideshowStop:'', rel: function() { return $(this).data('rel')} }); if (location.hash) $(location.hash).collapse('show'); //when this line is commented, Angular Route works properly }); 

    奇怪的是,只有在加载带有链接的页面时才会发生错误,例如localhost/index.html#/main或只是在选择任何视图的情况下重新加载页面。