路由不适用于 HTML5-History-API [英] Routing does not work well with HTML5-History-API

查看:27
本文介绍了路由不适用于 HTML5-History-API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In a mean-stack web application, I use html5mode and have the following code in 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:

I have defined the following 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.

Then, I go to https://localhost:3000/addin/test, clicking on one leads me to https://localhost:3000/addin/test#%2Faddin%2Fhome, whereas I would want to go to https://localhost:3000/addin/home.

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

If I don't have office.js and history.js, clicking on one does lead me to https://localhost:3000/addin/home.

有谁知道如何转到 https://localhost:3000/addin/home 同时保留 office.jshistory.js>?

Does anyone know how to go to https://localhost:3000/addin/home while keeping office.js and history.js?

推荐答案

我找到了...就用

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

这篇关于路由不适用于 HTML5-History-API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆