reactjs - “DetailedHTMLProps”类型上不存在属性“索引”, HTMLLI元素>
问题描述
我正在使用 react-typescript 但在我的列表中index
但它会引发警告:
interface PropsSortableElement {
children: any;
index: any;
zIndex?: number;
}
export const SortableItem = SortableElement(({ children, index, zIndex }: PropsSortableElement) => {
const classes = useStyles();
return (
<li className={classes.sortableItem} index={index} style={{ zIndex: zIndex || 1 }}>
{children}
</li>
);
});
所以我收到一个警告index
:
TS2322: Type '{ children: any; className: string; index: any; style: { zIndex: number; }; }' is not assignable to type 'DetailedHTMLProps<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>'. Property 'index' does not exist on type 'DetailedHTMLProps<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>'.
怎么能解决?
解决方案
推荐阅读
- python - 如何解决 AttributeError:模块 'serial' 在 pyserial 中没有属性 'Serial'?
- sql-server - 复制新文章被添加到事务复制,快照生成但未应用,没有错误
- sql - 将 SUM 除以不同的计数并得到错误
- javascript - Node.js readline.on('line', fn()) 看不到换行符
- asp.net - HtmlEncode ckeditor 默认文本
- cucumber - `cucumber-glue` 范围和步骤成员变量有什么区别?
- java - ANDROID STUDIO - 布局背景(图像)不显示
- kotlin - 是否可以在 Corda 的合同测试中以编程方式在分类帐内创建多个交易?
- c# - Moq 如何验证通用功能参数?
- neoscms - 当设置了多个其他属性时,仅在检查器中显示一个属性