首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取错误回调错误更新logo.children、c_name.children、description.children

获取错误回调错误更新logo.children、c_name.children、description.children
EN

Stack Overflow用户
提问于 2021-12-16 05:13:26
回答 1查看 238关注 0票数 0

我无法更新图像和其他属性,如公司名称,公司信息。在终端中,它不显示任何错误。但是,当我在屏幕上运行代码时,没有任何happens.It显示错误,因为img是一个空元素标记,必须没有children,也不能使用dangerouslySetInnerHTML和回调错误来更新logo.children、c_name.children、description.children.But,然后相同的代码才能正常运行。我是新手,所以我不能解决这个错误。

代码语言:javascript
复制
from typing import Container, ValuesView
import dash
from dash.development.base_component import Component
import dash_core_components as dcc
import dash_html_components as html
from datetime import datetime as dt
from datetime import date
from dash.dependencies import Input, Output, State
from flask.helpers import url_for
import yfinance as yf
import pandas as pd
import plotly.graph_objs as go
import plotly.express as px

app = dash.Dash(__name__)
server = app.server
app.layout=html.Div(
    className="container",
    children=[
        html.Div(children=[
            html.H1("Welcome to stock dash app!",className="start",style={'color':'#ffffff'}),
            html.Div(children=[
                html.Div([
                    dcc.Input(id="stock_code",type='text',placeholder="Enter Stock Code",className="inputbox"),
                    html.Button('Submit',id='submit_button',className="submit_button",style={'color':'#fffbf5'})
                ]),
                html.Div(
                children=[
                # Date range picker input
                dcc.DatePickerRange(
                    id='date_range_picker',
                    min_date_allowed=date(1990,12,31),
                    initial_visible_month=date(2021,12,3),
                    end_date=dt.now(), 
                )
                ]),
                html.Div(
                className='button',
                children=[
                # Stock price button
                html.Button('Stock Price',id='Stock_price_button',className="stock_p_b",style={'color':'#fffbf5'}),
                html.Button('Forcast',id='Forcast_button',className="forecast_b",style={'color':'#fffbf5'}),
                
                ]
                ),
                html.Div(children=[
                    dcc.Input(id="days",type='number',placeholder="Number of Days",className="inputbox"),
                    html.Button('Indicator',id='Indicator_button',className="indicator_b",style={'color':'#fffbf5'})
                ]
                )
            ])
            ],
                 className='nav'),
        html.Div(
        [
            html.Div(
                children=[ 
                html.Img('',id='logo',className='company_logo'),
                html.H1('',id='c_name',className='company_name',style={'color':'#064635'})
                ],
                className="header"),
            html.Div( #Description
                     html.P('',id='description', className='c_desc',style={'color':'#064635'}),),
            html.Div(
                id='stock_graph'
                ),
            html.Div(
                id='indicator_graph'),
            html.Div(
                id='forcast_graph'
                )
            ],
        className="content"
    )
    ]
)
@app.callback(
    [
        Output(component_id="logo",component_property='children'),
        Output(component_id="c_name",component_property='children'),
        Output(component_id="description",component_property='children'),
    ],
    Input(component_id='stock_code',component_property='value'),
    State(component_id='submit_button',component_property='n_clicks')
)
def update_data(arg1, arg2):
    ticker = yf.Ticker(arg1)
    inf = ticker.info
    df = pd.DataFrame().from_dict(inf, orient="index").T
    return df['logo_url'],df['shortName'],df['longBusinessSummary']


if __name__ == '__main__':
    app.run_server(debug=True)
EN

回答 1

Stack Overflow用户

发布于 2021-12-18 20:29:58

正如错误提示的那样,html.Img不应该有孩子。将其作为src属性传递,它应该可以工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70374109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档