简体   繁体   English

用NODEJS中的超链接和按钮更改路线的正确方法是什么?

[英]What is the correct way to change the route with hyperlinks and buttons in NODEJS?

I need to change routes within certain pages, then I step from the backend and generate the values ​​automatically in the onclick of the buttons or in the hyperlink href ... 我需要更改某些页面内的路由,然后从后端开始并在按钮的onclick或超链接href中自动生成值...

NOTE: I pass the values ​​from the backend, because I use params, among others to achieve these values. 注意:我从后端传递值,因为我使用params等来实现这些值。

I am using NODEJS + EXPRESS 我正在使用NODEJS + EXPRESS

<!-- EM CONSTRUÇÃO -->
<header>
    <nav class="navbar navbar-expand navbar-light bg-lilas-2 fixed-top <%= informations.checking.has.ShopkeeperComparePage ? 'shadow' : null; %>">
        <div class="container-fluid d-flex justify-content-between">
            <div>
                <% if(informations.checking.has.HomePage) { %>
                    <button type="button" class="btn btn-default bg-transparent shadow-none" data-toggle="modal" data-target="#filter"><i class="menu-options-icon text-lilas-1"></i></button>
                <% } else if(informations.checking.has.ShoppingPage) { %>
                    <button onClick="document.location.replace('/home/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=<%= informations.HTTP.querys.Indicator %>')" type="button" class="btn btn-lg bg-transparent shadow-none"><i class="back-arrow-icon text-lilas-1"></i></button>
                <% } else if(informations.checking.has.ShopkeeperPage) { %>
                    <button onClick="document.location.replace('/shopping/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=<%= informations.HTTP.querys.Indicator %>')" type="button" class="btn btn-lg bg-transparent shadow-none"><i class="back-arrow-icon text-lilas-1"></i></button>
                <% } else if(informations.checking.has.ShopkeeperDetailsPage) { %>
                    <button onClick="document.location.replace('/lojista/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=<%= informations.HTTP.querys.Indicator %>')" type="button" class="btn btn-lg bg-transparent shadow-none"><i class="back-arrow-icon text-lilas-1"></i></button>
                <% } else if(informations.checking.has.ShopkeeperComparePage) { %>
                    <button onClick="document.location.replace('/lojistadetalhes/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=<%= informations.HTTP.querys.Indicator %>')" type="button" class="btn btn-lg bg-transparent shadow-none"><i class="back-arrow-icon text-lilas-1"></i></button>
                <% } %>

            </div>
            <div class="flex-fill text-center ml-4 pl-sm-2">
                <span class="navbar-brand text-white"><%= informations.page.general.titles.navbar %></span>
            </div>
            <div>
                <% if(informations.checking.has.ShopkeeperDetailsPage) { %>
                    <button onClick="(document.getElementById('BTNSWI').getAttribute('data-indicator') === 'm²') ? document.location.replace('/<%= informations.page.general.type %>/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&Storename=<%= informations.HTTP.querys.Storename %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=M2') : document.location.replace('/<%= informations.page.general.type %>/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&Storename=<%= informations.HTTP.querys.Storename %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=ABS');" type="button" id="BTNSWI" class="btn btn-sm btn-switch-indicator shadow-none" data-toggle="button" data-indicator="<%= (informations.page.data.API.indicatorType === 'm²') ? 'abs' : 'm²' %>" aria-pressed="false" autocomplete="off">
                        <div id="teste" class="handle-switch-indicator"></div>
                    </button>
                <% } else { %>
                    <button onClick="(document.getElementById('BTNSWI').getAttribute('data-indicator') === 'm²') ? document.location.replace('/<%= informations.page.general.type %>/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=M2') : document.location.replace('/<%= informations.page.general.type %>/v1/query?Shop=<%= informations.HTTP.querys.Shop %>&PeriodOf=<%= informations.HTTP.querys.PeriodOf %>&PeriodUntil=<%= informations.HTTP.querys.PeriodUntil %>&PeriodType=<%= informations.HTTP.querys.PeriodType %>&Indicator=ABS');" type="button" id="BTNSWI" class="btn btn-sm btn-switch-indicator shadow-none" data-toggle="button" data-indicator="<%= (informations.page.data.API.indicatorType === 'm²') ? 'abs' : 'm²' %>" aria-pressed="false" autocomplete="off">
                        <div id="teste" class="handle-switch-indicator"></div>
                    </button>
                <% } %>
            </div>
        </div>
    </nav>
</header>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM