arco-design-vue icon indicating copy to clipboard operation
arco-design-vue copied to clipboard

表格组件 align: 'center' 报类型错误

Open 981433814 opened this issue 3 years ago • 2 comments

Basic Info

What is expected?

{ title: '操作', align: 'center', slotName: 'optional', }, 这样指定 align 居然报错,我不知道为什么 Type 'string' is not assignable to type '"left" | "right" | "center" | undefined'.

981433814 avatar Jul 29 '22 03:07 981433814

@981433814 你好,类型约束的问题,typescript 默认将 align 的类型识别为 string, 这里需要是 '"left" | "right" | "center" | undefined' 类型,声明一下对象的类型就好,属于 typescript 的类型约束问题(搜索下)

hehehai avatar Aug 02 '22 08:08 hehehai

可以通过

{
title: '操作',
align: 'center' as const,
slotName: 'optional',
},

解决。这里一般建议使用提供的 TableColumnData 类型声明下变量

flsion avatar Aug 05 '22 07:08 flsion