我是使用 Typescript 和 React 的新手,如果這是一個新手問題,我很抱歉。在我的代碼中,我有以下行:<p><span href="#" id="nsTool" style={{color:"white", width: "50px"}}> Namespace </span></p>當代碼僅使用 Javascript/React 時,這最初工作正常,但當我將文件轉換為 .tsx(Typescript)時,出現以下錯誤:Type '{ children: string[]; href: string; id: string; style: { color: string; width: string; }; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>'. Property 'href' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>'.這是否意味著我不能在 span 元素中使用 href ?我該如何解決這個問題?
- 2 回答
- 0 關注
- 253 瀏覽
添加回答
舉報
0/150
提交
取消