瀏覽代碼

adding demo with sub pages and prefix

Rodja Trappe 2 年之前
父節點
當前提交
d5e460f325
共有 1 個文件被更改,包括 12 次插入3 次删除
  1. 12 3
      examples/modularization/c.py

+ 12 - 3
examples/modularization/c.py

@@ -2,10 +2,19 @@ import theme
 
 
 from nicegui import APIRouter, ui
 from nicegui import APIRouter, ui
 
 
-router = APIRouter()
+router = APIRouter(prefix='/c')
 
 
 
 
-@router.page('/c')
+@router.page('/')
 def example_page():
 def example_page():
     with theme.frame('- Example C -'):
     with theme.frame('- Example C -'):
-        ui.label('Example C').classes('text-h4 text-grey-8')
+        with ui.column().classes('items-center'):
+            ui.label('Example C').classes('text-h4 text-grey-8')
+            for i in range(1, 4):
+                ui.link(f'Item {i}', f'/c/items/{i}').classes('text-xl text-grey-8')
+
+
+@router.page('/items/{id}')
+def item(id: str):
+    with theme.frame(f'- Example C{id} -'):
+        ui.label(f'Item  #{id}').classes('text-h4 text-grey-8')