satrong / element-ui-types

为 ElementUI 提供在 Volar 下的类型支持

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide types support for ElementUI under Volar.

Install and usage

1. Install element-ui-types

npm i element-ui-types -D

# Or
pnpm add element-ui-types -D

2. Add the following configuration to tsconfig.json

// tsconfig.json
{
  "vueCompilerOptions": {
    "target": 2.7,
    // "target": 2, // For Vue version <= 2.6.14
  },
  "compilerOptions": {
    "types": ["element-ui-types"]
  }
}

3. Reload IDE

Demo

<template>
  <ElForm ref="formRef">
    ...
  </ElForm>
</template>

<script lang="ts" setup>
import { type Form } from 'element-ui'

const formRef = ref<InstanceType<typeof Form>>()

formRef.value?.validate(valid => {
  // `valid` is type of  `boolean`
})
</script>

About

为 ElementUI 提供在 Volar 下的类型支持

License:MIT License


Languages

Language:JavaScript 55.9%Language:TypeScript 29.9%Language:Shell 14.2%