search

Home  >  Q&A  >  body text

angular.js - angularjs和jquery-mobile关于前端路由冲突

目前就是刷新局部视图,jquery-mobile的某些样式会失效,需要强制刷新整个页面。
如何刷新整个页面?

补充:如果使用location.replace(),先是location.replace('page/page1.html)这样直接定位到具体位置,这样的话只会那个页面的代码,实际上那个页面是一个模板页面,那么那个模板页面就是纯HTML,无CSS部分。
然后用location.replace(#page1)这样只是切换了局部视图,并没有什么效果。
如果是$location.reload()那么会跳转到路由里/定义的位置,不是刷新当前页面………………
如何刷新当前整个页面?或者

路由里如何配置,刷新页面是是刷新当前页面,而非跳转到首页?

如果当前页面是http://localhost:8080/#/setting
F5后是http://localhost:8080/setting#/
那么路由到otherwise,也就是/

原问题:angular如何刷新整个页面?

大家讲道理大家讲道理2744 days ago890

reply all(4)I'll reply

  • PHPz

    PHPz2017-05-15 16:55:12

    Solution process

    You need to force refresh the entire page. Partial refresh is not possible
    It’s the effect of F5
    =====================>
    Found after refreshing url会变化
    If the url does not change, then we can use window.reload
    So we need to solve the problem of URL changes
    =====================>
    Because the page keeps reporting error loading page error
    I checked and this is from jquery-mobile
    Then I blocked the JS and CSS files of JQM and found URL变化是JQM引起的
    Find related solutions
    =====================>
    Oh, if you want to persistjquery-mobile+angular
    You need to use jqm's page jump.
    =====================>
    Front-end UI framework by jquery-mobile替换为bootstrap

    Conclusion

    jqm和angular关于前端路由方面有冲突,
    If you insist on using jqm, you cannot use angular's front-end routing. You must use jqm's jq to write page jumps, which may cause the page to be messy.
    So it took half a day to replace it with bootstrap.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-15 16:55:12

    location.href? location.hash?

    reply
    0
  • 高洛峰

    高洛峰2017-05-15 16:55:12

    If this is not easy to use, just use jquery, what do you think

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 16:55:12

    I don’t know why, but I really want to help you when I see your situation. Currently I am also integrating JQM and Angularjs and have some ideas!
    Specifically, configure some parameters when initializing jqm:

        $( document ).on( "mobileinit", function() {
            $.mobile.page.prototype.options.domCache = false;// 关闭缓存
            $.mobile.initializePage = false;
            $.mobile.defaultPageTransition = "fade";
            $.mobile.autoInitializePage = true;
            $.mobile.hideUrlBar = false;
            $.mobile.linkBindingEnabled = false;
            $.mobile.hashListeningEnabled = false;
            $.mobile.ajaxEnabled = false;
    
        });

    Please refer to the official API documentation for each configuration.
    One of these configurations is to solve the URL conflict problem, which is to turn off JQM routing.

    reply
    0
  • Cancelreply