如何将html列表添加到破折号布局

问题描述 投票:1回答:1

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

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 a
  • 等等 ...
python plotly plotly-dash
1个回答
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')。你可能已经知道回调将带来什么输入,但这不是你的帖子的一部分,所以我把它留了出来。

© www.soinside.com 2019 - 2024. All rights reserved.