本文介绍了路由不适用于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.

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

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

推荐答案

我发现了它...只需使用

I found it... just use

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

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

10-15 08:02