![](/img/trans.png)
[英]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.