[英]Test method called in mounted hook Vue class component typescript
[英]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.