2017-03-18 94 views
0

我在我的angular2應用程序中實現了swagger-ui(swagger-ui.js)。當它被渲染時,我點擊任何鏈接(#!users/get_user)它會路由到鏈接而不是滾動到該div。在angular2中使用錨標籤的相同頁面路由

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 --> 

回答

0

我修好了。我改變了swagger-ui.js。

我將href更改爲href =「」,用於單擊時導致路由的元素。

這是一種解決方法,但它現在可行。 :)

相關問題