Routing 使用sammy.js的绝对URL路由

Routing 使用sammy.js的绝对URL路由,routing,sammy.js,Routing,Sammy.js,我有一个绝对的URL: <a href="https://circleci.com/docs/configuration">configuration</a> 我使用Sammy.js进行路由,但它不会路由它。但是,它很乐意路由相同URL的相对版本: <a href="/docs/configuration">configuration</a> 如何以同样的方式使sammy route成为绝对版本?您仍然可以在href中使用哈希,即hre

我有一个绝对的URL:

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

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

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


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

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

然后使用Sammy捕获路由并使用
位置。分配
方法加载新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();