【问题标题】:Routing does not work well with HTML5-History-API路由不适用于 HTML5-History-API
【发布时间】:2017-12-12 14:03:43
【问题描述】:

在平均堆栈 Web 应用程序中,我使用 html5mode 并在 index.html 中有以下代码:

<base href="/" />   
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
<script src="https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js"></script>

我已经定义了以下 angular-ui-router:

    .state('addinHome', {
        url: '/addin/home',
        template: "home page"
    })
    .state('addinTest', {
        url: '/addin/test',
        template: '<a href="addin/home">one</a>',
        controller: 'TestCtrl'
    })

然后,我转到https://localhost:3000/addin/test,点击one 会转到https://localhost:3000/addin/test#%2Faddin%2Fhome,而我想转到https://localhost:3000/addin/home

如果我没有office.jshistory.js,点击one 会引导我到https://localhost:3000/addin/home

有谁知道如何在保持office.jshistory.js 的同时转到https://localhost:3000/addin/home

【问题讨论】:

    标签: javascript angularjs angular-ui-router html5-history html5mode


    【解决方案1】:

    我找到了...只需使用

    template: '<a href="addin/home" target="_self">one</a>'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-13
      • 2019-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多