TypeScript 支持
VEUI 提供了组件 API 的 TS 声明,需要配合 Volar
获得最佳的开发体验。
如果您使用 npm < 7 或其他不会自动安装 peerDependencies 的包管理器,需要手动安装:
npm i -D @vue/runtime-dom
配置 Volar 扩展
请参考 Volar
文档中的 Setup for Vue2
。
本地配置
在 tsconfig.json
中添加如下配置来支持 Vue 2
的模板语法。
{
"vueCompilerOptions": {
"experimentalCompatMode": 2,
"experimentalTemplateCompilerOptions": {
"compatConfig": { "MODE": 2 }
}
}
}
使用示例
<template>
<veui-button>OK</veui-button>
</template>
<script lang="ts">
import { defineComponent } from '@vue/composition-api'
import { Button } from 'veui'
export default defineComponent({
components: {
'veui-button': Button
}
})
</script>