小编Haa*_*mus的帖子

Dash Bootstrap 组件 NavLink 不触发回调

我正在创建一个多页面应用程序,并且创建了一个导航栏,其中包含指向不同页面(URL)的链接,该导航栏最近神秘地停止工作。我尝试将所有代码恢复到最后一次已知的良好状态,但它没有修复问题。目前,这仅在我的开发计算机上被破坏,实时应用程序仍然有效,但由于这个问题,我无法发布新版本。我在下面包含了所有相关代码的代码片段,并且希望能以新的眼光来看待这个问题,谢谢。

可能值得注意的是,如果我将 dbc.NavLink 更改为 dbc.Link 一切正常,但它布局不正确或在页面中具有活动按钮外观,因此这不是所需的选项。

这是我的版本

dash-bootstrap-components 0.7.1
dash-core-components 1.8.0
dash-html-components 1.0.2
Run Code Online (Sandbox Code Playgroud)

应用程序.py

import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html

from server import app

app.layout = htm.Div([
    html.Link(rel='shortcut icon', href='assets/images/favicon/ico'),
    dcc.Store(id='session-store', storage_type='session'),
    dcc.Location(id='url', refresh=False),
    html.Nav(id='navbar-container'),
    html.Div(id='page-content')
])
Run Code Online (Sandbox Code Playgroud)

导航栏.py

import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html

def navbar():
    layout = html.Nav([
        dbc.Nav([
            dbc.NavItem(dbc.NavLink('Home', id='home-link', href='/')),
            dbc.NavItem(dbc.NavLink('Employees', id='employee-link', href='/employees')),
            dbc.NavItem(dbc.NavLink('Programs', id='programs-link', href='/programs')),
            dbc.NavItem(dbc.NavLink('Capacity', id='capacity-link', href='/capacity'))
            ],
            pills=True,
            id='navbar')
    ])
Run Code Online (Sandbox Code Playgroud)

回调.py

from …
Run Code Online (Sandbox Code Playgroud)

python navbar multi-page-application

6
推荐指数
1
解决办法
3513
查看次数

标签 统计

multi-page-application ×1

navbar ×1

python ×1