我正在尝试设置一个带有类型记录的Vue3项目。
我得到了错误:"File‘/home/./src/App.vue.ts’不是一个模块“。
当在main.js中使用Javascript时,它工作得很好,但是当将它重命名为main.ts时,我无法导入".vue“文件。
Main.ts:
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
createApp(App).use(router).mount('#app');现在,当运行yarn serve时,输出显示:
ERROR in src/main.ts:2:17
TS2306: File '/home/.../src/App.vue.ts' is not a module.
1 | import { createApp } from 'vue';
> 2 | import App from './App.vue';
| ^^^^^^^^^^^
3 | import router from './router';怎样才能让打字本理解.vue-files?
发布于 2021-03-26 13:10:37
结果,我应该将“导出默认{}”添加到我的App.vue文件中。
原始(错误) App.vue:
<template>
<router-view></router-view>
</template>
<script lang="ts">
console.log('Loading App.vue');
</script>我通过添加“exportdefault{};”来修正错误。
新的App.vue:
<template>
<router-view></router-view>
</template>
<script lang="ts">
console.log('Loading App.vue');
export default {}; // <-- added this line to fix the error
</script>https://stackoverflow.com/questions/66816568
复制相似问题