1

我有一个绝对的 URL:

<a href="https://circleci.com/docs/configuration">configuration</a>

我使用 Sammy.js 进行路由,但它不会路由它。但是,很高兴路由相同 URL 的相对版本:

<a href="/docs/configuration">configuration</a>

如何以相同的方式使 sammy route 成为绝对版本?

4

1 回答 1

0

您仍然可以在您的 中使用哈希href,即href="#ESPN"

然后使用 Sammy 捕获路由并使用该location.assign方法加载新 URL 或检索文档:

Sammy(function () {
    /* Top-bar navigation requests
    */
    this.get("#:view", function () {
        switch (this.params.view) {              
            case "ESPN":
                location.assign("http://www.espn.com")
                break;    
        };
    });

    /* Reporting Excel requests
    */
    this.get("#Reporting/Excel/:type/:audience/:unitID/:departmentID", function () {
        location.assign("Report/Excel?" +
            "Type=" + this.params.type + "&" +
            "Audience=" + this.params.audience + "&" +
            "UnitID=" + this.params.unitID + "&" +
            "DepartmentID=" + this.params.departmentID
        );
    });
}).run();
于 2012-11-29T19:34:02.553 回答