超全模态模型 × Harness 升级,升级解锁 ArkClaw,最新支持 DeepSeek-V4 系列与 GLM-5.1
你当前的写法存在两个关键问题:
children
ReactNode
Array<object>
先明确每个菜单数据的结构,同时把class改成className(JSX中不能使用class关键字):
class
className
interface MenuItem { text: string; href: string; className: string; }
改用专门的menuItems属性接收菜单数据,避免滥用children:
menuItems
// TopBar.tsx import React from 'react'; import Link from 'next/link'; import ImgBlock from './ImgBlock'; // 假设你已定义该组件 interface MenuItem { text: string; href: string; className: string; } interface TopBarProps { menuItems: MenuItem[]; } export default function TopBar({ menuItems }: TopBarProps) { return ( <div className="pl-4 pr-16 flex items-center h-16 w-screen justify-between border-b-gray-200 border-2 fixed bg-white z-10"> <ImgBlock src="/assets/svg/logo.png" width="7rem" height="4rem"/> <div className="flex gap-8 items-center"> {menuItems.map((item, index) => ( <Link key={index} className={item.className} href={item.href}> {item.text} </Link> ))} </div> </div> ); }
把数组传给menuItems属性,不再作为children传递:
// page.tsx ... <TopBar menuItems={[ {text:"career",href:"",className:"p-0 m-0"}, {text:"contact",href:"",className:"p-0 m-0"}, {text:"patient registry",href:"/patient_registry",className:"custom-outline p-1 rounded-2xl px-4 hover:bg-black hover:text-white"} ]} /> ...
如果一定要通过children传数组,需要手动断言类型,但这种写法不规范:
// TopBar.tsx import React, { ReactNode } from 'react'; interface MenuItem { text: string; href: string; className: string; } export default function TopBar({ children }: { children: ReactNode }) { // 断言children为MenuItem数组,需确保传入数据类型匹配 const menuItems = children as unknown as MenuItem[]; return ( <div className="pl-4 pr-16 flex items-center h-16 w-screen justify-between border-b-gray-200 border-2 fixed bg-white z-10"> <ImgBlock src="/assets/svg/logo.png" width="7rem" height="4rem"/> <div className="flex gap-8 items-center"> {menuItems.map((item, index) => ( <Link key={index} className={item.className} href={item.href}> {item.text} </Link> ))} </div> </div> ); }
object
内容的提问来源于stack exchange,提问作者レノキ乇1ᑌᑭ
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起
模型再升级,30秒超长叙事, 模态参考扩容
模型自由,工具不限,最新支持 Deepseek-V4 系列、GLM-5.3 系列
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列
大模型19元起,Al应用9.9元畅享,新人首购爆款尽享优惠