【问题标题】:how to add html lists to dash layout如何将 html 列表添加到破折号布局
【发布时间】:2019-05-01 10:48:03
【问题描述】:

我需要在屏幕上的特定位置动态添加一个单词列表到破折号布局(意思是单词列表随时间变化):

import dash
from dash.dependencies import Output, Input
import dash_core_components as dcc
import dash_html_components as html
import plotly
import plotly.graph_objs as go



app = dash.Dash(__name__)


trends =['python', 'flask', 'jave']

html_lists = []


trends =['python', 'flask', 'jave']

app.layout = html.Div(
    html.Div(
        className="trend",
        children=[
            html.Ui(
                for i in trends:
                    html.Li(i))
        ], )
    )
print(html_ul_list)
if __name__ == '__main__':
    app.run_server(debug=True)

我需要网页上的输出在屏幕右侧是这样的:

趋势

  • 蟒蛇
  • java 一个

  • 等等……

【问题讨论】:

    标签: python plotly plotly-dash


    【解决方案1】:

    您有几个小错误。我对此进行了测试,它可以工作:

    app = dash.Dash(__name__)
    
    trends = ['python', 'flask', 'java']
    
    app.layout = html.Div(
        html.Div(
            className="trend",
            children=[
                html.Ul(id='my-list', children=[html.Li(i) for i in trends])
            ],
        )
    )
    
    if __name__ == '__main__':
        app.run_server(debug=True)
    

    要让这个列表动态更新,您需要连接一个回调,输出如下:Output('my-list', 'children')。您可能已经知道回调将接受哪些输入,但这不是您帖子的一部分,所以我省略了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-25
      • 2022-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多