【问题标题】:same page route using anchor tag in angular2在angular2中使用锚标记的相同页面路由
【发布时间】:2017-03-18 11:31:49
【问题描述】:

我已经在我的 angular2 应用程序中实现了 swagger-ui(swagger-ui.js)。当它被渲染并且我点击任何链接(#!users/get_user)时,它会路由到链接而不是滚动到那个 div。

window['swaggerUi'] = new window['SwaggerUi']({
                spec: this.swaggerJson,
                dom_id: "swagger-ui-container",
                supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
                useJQuery: true,
                onComplete: function () {
                    }
                    window['jQuery']('pre code').each(function (i, e) {
                        window['hljs'].highlightBlock(e)
                    });
                },
                onFailure: function (data) {
                    console.log("Unable to Load SwaggerUI");
                },
                docExpansion: "none",
                sorter: "alpha"
            });

包含 href 的链接正在路由,但包含 data-id 的链接工作正常。 我怎样才能阻止这些链接的路由。

 <a href="#!/users/get_users_userid" class="toggleOperation">Users</a> 
 <!-- routes to that url(localhost:8080/#!/users/get_users_userid) -->

 <a href="#" class="expandResource" data-id="users">Expand Operations</a> 
 <!-- it expands the div -->

【问题讨论】:

    标签: angular angular2-routing swagger-ui


    【解决方案1】:

    我修好了。我在 swagger-ui.js 中进行了更改。

    我将点击时导致路由的元素的 href 更改为 href=""。

    这是一种解决方法,但现在可以使用。 :)

    【讨论】:

      猜你喜欢
      • 2016-07-06
      • 1970-01-01
      • 2015-11-30
      • 2017-03-29
      • 2023-04-08
      • 2016-04-08
      • 1970-01-01
      • 2016-06-04
      • 1970-01-01
      相关资源
      最近更新 更多