vue3 element Plus全局组件类型声明
时间: 2023-08-02 17:05:03 浏览: 386
以下是Vue3 Element Plus中常用全局组件的类型声明:
```typescript
// ElButton
import { ElButton } from 'element-plus'
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
$ELEMENT: {
size: string
zIndex: number
}
}
}
// ElInput
import { ElInput } from 'element-plus'
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
$ELEMENT: {
size: string
zIndex: number
input: {
suffixIconClass: string
prefixIconClass: string
}
}
}
}
// ElSelect
import { ElSelect } from 'element-plus'
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
$ELEMENT: {
size: string
zIndex: number
select: {
arrowIconClass: string
collapseTag: boolean
}
}
}
}
// ElTable
import { ElTable } from 'element-plus'
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
$ELEMENT: {
size: string
zIndex: number
table: {
highlightCurrentRow: boolean
stripe: boolean
border: boolean
}
}
}
}
```
需要注意的是,这里使用了 TypeScript 进行类型声明。如果你使用的是 JavaScript,那么可以将类型声明去掉。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)