我和孩子们吵架,在第一次加载时,一切正常,但是一旦我盯着网站,组件开始呈现两次。我不确定我做错了什么。 这是路由顶层结构:
from tkinter import *
from tkinter import ttk
def start():
w.start()
def stopfunc():
w.stop()
#var.set(var.get())
def reset():
var.set(0)
window = Tk()
var = IntVar()
w = ttk.Progressbar(window, variable=var)
w.pack()
button1 = ttk.Button(window, text = 'start', command = start)
button1.pack()
button2 = ttk.Button(window, text = 'stop', command = stopfunc)
button2.pack()
button2 = ttk.Button(window, text = 'reset', command = reset)
button2.pack()
window.mainloop()
然后这些是儿童路线: OptionOne 组件
<React.Suspense fallback={<span>Loading...</span>}>
<Switch>
<Route path={"/dashboard/optionOne"} component={OptionOne} />
<Route path={"/dashboard/OptionTwo"} component={OptionTwo}/>
<Switch>
</React.Suspense>
OptionTwo 组件
<Switch>
<Route exact path={path} component={OptionOneContainer}/>
<Route path={`${path}/subChildOne`} component={SubChildOne}/>
<Route path={`${path}/:subChildTwo`} component={SubChildTwo}/>
</Switch>
我有一个顶部组件标题,可帮助浏览网站仪表板:
<Switch>
<Route exact path={path} component={OptionTwoContainer}/>
<Route path={`${path}/OptionTwoSubChildOne`} component={OptionTwoSubChildOne}/>
<Route path={`${path}/:OptionTwoSubChildTwo`} component={OptionTwoSubChildTwo}/>
</Switch>
一旦点击链接导航甚至使用history.push,组件渲染两次。 有什么建议吗?