简体   繁体   中英

Vue typescript class component with vuedraggable

I am having error when importing sortableJs/vuedraggable with TS class component .

When using vuedraggable with standard JS standard component it's working fine.

here's my vuedraggable with standard JS component :

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

everything is working no error.

here's my vuedraggable with TS class component :

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

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

here error occurred

Could not find a declaration file for module 'vuedraggable'.

implicitly has an 'any' type. Try npm install @types/vuedraggable if it exists or add a new declaration (.d.ts) file containing `declare module 'vuedraggable

so I did :

npm install @types/vuedraggable

npm ERR! 404 '@types/vuedraggable@latest' is not in the npm registry.

How can I use vuedraggable in a Typescript CLass Component?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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