arco-design-vue
arco-design-vue copied to clipboard
表格组件 align: 'center' 报类型错误
- [ ] I'm sure this does not appear in the issue list of the repository
Basic Info
- Package Name And Version: @arco-design/[email protected]
- Browser: chrome103.0.0.0
What is expected?
{ title: '操作', align: 'center', slotName: 'optional', }, 这样指定 align 居然报错,我不知道为什么 Type 'string' is not assignable to type '"left" | "right" | "center" | undefined'.
@981433814 你好,类型约束的问题,typescript 默认将 align 的类型识别为 string, 这里需要是 '"left" | "right" | "center" | undefined' 类型,声明一下对象的类型就好,属于 typescript 的类型约束问题(搜索下)
可以通过
{
title: '操作',
align: 'center' as const,
slotName: 'optional',
},
解决。这里一般建议使用提供的 TableColumnData 类型声明下变量