我正在尝试使用React.js和bootstrap创建导航栏,我有几个组件,不知道如何使菜单中的链接工作,问题是子路由,当我想访问路径之类的路径='/ book / booktwo'它只是不起作用,但更简单的个别路线确实有效。这是我的代码。谢谢!!!
import math
import tkinter as tk
from tkinter import *
import matplotlib
import matplotlib.pyplot as plt
from numpy import arange, sin, cos, tan, pi
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
NavigationToolbar2TkAgg
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
from matplotlib.patches import Circle
# Initialising the graph
f = Figure(figsize=(6, 6), dpi=100)
a = f.add_subplot(111)
root = tk.Tk()
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.pack()
self.mainwindow()
def mainwindow(self):
self.add_loci = Button(self)
self.add_loci["text"] = "Add Line"
self.add_loci["command"] = self.line
self.add_loci.pack(side = TOP)
# Plotting an empty graph
a.set_xlabel('Re')
a.set_ylabel('Im')
a.grid(b=None)
a.plot(0, 0)
# Setting up and showing the toolbar and the graph
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().pack(side = BOTTOM, fill=BOTH, expand=1)
toolbar = NavigationToolbar2TkAgg(canvas, root)
toolbar.update()
canvas._tkcanvas.pack(side = BOTTOM, fill=BOTH, expand=1)
def line(self):
a.plot([0, 10], [0, 10])
print('test')
app = Application(master=root)
app.mainloop()
答案 0 :(得分:0)
使用path={'/book/:id'}
代替path='{/book/:id}'
答案 1 :(得分:0)
我认为有两个问题:
您的引号位于花括号之外。尝试将其写为path={'/books'}
等
您对指向浏览器的路线不够具体。你的三个子路由都匹配第一个字符,这可能会使它混淆,认为它是路由到'/'
。我通常使用exact path={/*string*/}
来确保路由器不会混淆。 (虽然我不确定这是否会导致任何问题,因为它至今尚未出现)