Vue 3 TypeError(猫头鹰轮播)

时间:2021-01-03 16:32:43

标签: javascript typescript vue.js typescript-typings owl-carousel

我目前正在使用打字稿在 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>

当我打开页面时,我得到一个空白页面,并且在控制台中出现此错误: enter image description here

0 个答案:

没有答案