Dash App Table 链接不可点击 - Python Web 应用程序问题
Dash App Table links are not clickable - Python Web app issue
Dash App Table 不允许点击链接。当我将鼠标悬停在标题上时,它们似乎是可点击的链接,但当我点击它们时没有任何反应。
以下是我用来构建 table:
的函数
def build_rows(images,titles,author,category,price,link):
"""
builds a table body. All parameters expect a list type
"""
rows = []
for x in range(len(titles)):
rows.append(html.Tr([html.Img(src=images[x], height="100px"),
html.Td(dcc.Link(titles[x], href=link[x])), # <--- This the problem
html.Td(author[x]),
html.Td(category[x]),
html.Td(price[x]),
html.Td(link[x])]))
table_body = [html.Tbody(rows)]
return table_body
感谢您的帮助。
注意:我总是在适用时投票 select 正确答案
如果您只想要一个带有 href 的常规锚标记,那么您想使用 html.A
(即 import dash_html_components as html
)而不是 dcc.Link
。
dcc.Link
组件与 dcc.Location
组件一起使用,并允许通过将回调函数连接到当前 URL 的值来创建单页应用程序,将不同的布局片段返回到特定的容器元素中。如果这是您要尝试执行的操作,请参阅 docs 了解如何使用 Location
组件。
Dash App Table 不允许点击链接。当我将鼠标悬停在标题上时,它们似乎是可点击的链接,但当我点击它们时没有任何反应。
以下是我用来构建 table:
的函数def build_rows(images,titles,author,category,price,link):
"""
builds a table body. All parameters expect a list type
"""
rows = []
for x in range(len(titles)):
rows.append(html.Tr([html.Img(src=images[x], height="100px"),
html.Td(dcc.Link(titles[x], href=link[x])), # <--- This the problem
html.Td(author[x]),
html.Td(category[x]),
html.Td(price[x]),
html.Td(link[x])]))
table_body = [html.Tbody(rows)]
return table_body
感谢您的帮助。 注意:我总是在适用时投票 select 正确答案
如果您只想要一个带有 href 的常规锚标记,那么您想使用 html.A
(即 import dash_html_components as html
)而不是 dcc.Link
。
dcc.Link
组件与 dcc.Location
组件一起使用,并允许通过将回调函数连接到当前 URL 的值来创建单页应用程序,将不同的布局片段返回到特定的容器元素中。如果这是您要尝试执行的操作,请参阅 docs 了解如何使用 Location
组件。