import{Route,Router,typeRouteSectionProps}from"@solidjs/router";importtype{JSXElement}from"solid-js";import{render}from"solid-js/web";importNotFoundfrom"./NotFound.tsx";functionLayout(props: RouteSectionProps):JSXElement{return(<><header>header</header><hr/>{props.children}<hr/><footer>footer</footer></>);}constroot=document.getElementById("root");if(!root){thrownewError("root not found");}functionChild2():JSXElement{return<div>Child2</div>;}functionChild1():JSXElement{return<div>Child1</div>;}functionMain():JSXElement{return<div>Main</div>;}functionRouterComponent():JSXElement{return(<Router><Routepath="/"component={Layout}><Routepath="/"component={Main}/><Routepath="child1"component={Child1}/><Routepath="child2"component={Child2}/></Route><Routepath="*"component={NotFound}/></Router>);}render(RouterComponent,root);
import{Route,Router}from"@solidjs/router";import{typeJSX,typeJSXElement}from"solid-js";import{render}from"solid-js/web";constroot=document.getElementById("root");if(!root){thrownewError("root not found");}functionHome():JSX.Element{return<div>"Home"</div>;}functionAbout():JSX.Element{return<div>"About"</div>;}functionLayout(props:{children?: JSXElement}):JSXElement{return(<><header>Header</header>{props.children}<footer>Footer</footer></>);}functionRouterComponent():JSXElement{return(<Routerroot={Layout}><Routepath="/"component={Home}/><Routepath="/about"component={About}/></Router>);}render(()=><RouterComponent/>,root);
import{Route,Router,useParams}from"@solidjs/router";import{typeJSXElement}from"solid-js";import{render}from"solid-js/web";constroot=document.getElementById("root");if(!root){thrownewError("root not found");}functionChild2():JSXElement{interfaceParam{id: string;[key: string]:string;}constparam=useParams<Param>();return<>{param.id}</>;}functionRouterComponent():JSXElement{return(<Router><Routepath="/"><Routepath="child2/:id"component={Child2}/></Route></Router>);}render(()=><RouterComponent/>,root);