我目前正在使用打字稿在 vue 3 中工作。 我想使用 vue owl 库 (https://www.npmjs.com/package/vue-owl-carousel)。
但是,我收到一条消息,我需要声明它,我按如下操作:
tsconfig.json
"compilerOptions": {
...
"include": [
...
"src/owl/index.d.ts"
],
...
}
owl index.d.ts
declare module "vue-owl-carousel";
vue 组件
<template>
<div class="hello">
<carousel>
<img src="https://placeimg.com/200/200/any?1">
<img src="https://placeimg.com/200/200/any?2">
<img src="https://placeimg.com/200/200/any?3">
<img src="https://placeimg.com/200/200/any?4">
</carousel>
</div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import carousel from "vue-owl-carousel";
@Options({
components: {
carousel
}
})
...
</script>