繁体   English   中英

带有 vuedraggable 的 Vue 打字稿类组件

[英]Vue typescript class component with vuedraggable

使用TS class component导入 sortableJs/vuedraggable 时出错。

vuedraggable与标准JS standard component一起使用vuedraggable ,它工作正常。

这是我的带有标准 JS 组件的vuedraggable:

<script>
import draggable from "vuedraggable";
export default {
  components: {
    draggable
  },
...

一切正常,没有错误。

这是我的带有TS 类组件的vuedraggable :

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import draggable from "vuedraggable";

@Component({
  components: {
    draggable
  }
})
export default class Board extends Vue {
...

这里发生错误

找不到模块“vuedraggable”的声明文件。

隐式具有“任何”类型。 如果存在,请尝试npm install @types/vuedraggable或添加包含 `declare module 'vuedraggable 的新声明 (.d.ts) 文件

所以我做了 :

npm install @types/vuedraggable

npm 错误! 404 '@types/vuedraggable@latest' 不在 npm 注册表中。

如何在 Typescript 类组件中使用 vuedraggable?

您可以创建一个本地类型文件并添加vuedraggable的声明,如this github issue中所述作为解决方法,直到将类型添加到库PR合并。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM