如何修改element-plus的默认类型?

问题描述 投票:0回答:1

比如el-button的类型是

'' | 'text' | 'default' | 'success' | 'warning' | 'info' | 'primary' | 'danger'
,如何追加类型
cancel

'' | 'text' | 'default' | 'success' | 'warning' | 'info' | 'primary' | 'danger' | 'cancel'

typescript element-plus
1个回答
0
投票

您无法修改或覆盖现有类型。但是,您可以简单地使用另一种联合类型,如下所示:

type ElButton =
  | ""
  | "text"
  | "default"
  | "success"
  | "warning"
  | "info"
  | "primary"
  | "danger";
type Appended = ElButton | "cancel";
//   ^? type Appended = ElButton | "cancel"

TypeScript 游乐场

© www.soinside.com 2019 - 2024. All rights reserved.