1. dash的框架
当你准备开始写一个dash app的时候,第一步就是搭建它的框架,我用的是python:
a. 导入包
import dash
from dash import html
b. 创建应用
app = dash.Dash(__name__)
c. 创建应用的布局
app.layout = html.Div(children = [
html.H1(),
html.Dropdown(),
html.Graph(),
......
])
d.运行应用程序
if __name__ == '__main__':
app.run_server(debug = True)
2. 创建你的第一个dash app
我们利用上述介绍中的框架创建你的第一个dash app。这里用了html.H1将文字部分显示成一级标题。debug = True,在页面上会出现debug工具,当改成False后就不会显示。
import dash
from dash import html
app = dash.Dash(__name__)
app.layout = html.Div(children = [
html.H1("这是我的第一个dash app!")
])
if __name__ == '__main__':
app.run_server(debug = True)
最终的页面显示,右下角的蓝色圆圈就是debug工具。