【发布时间】:2022-01-08 03:29:39
【问题描述】:
我的堆栈是 Nuxtjs 和 Nuxt-property-decorator
我做了一个 mixin 来避免重复一个方法
该方法需要一个组件(警报组件)
所以,我在 mixin 中导入了那个组件
但是我在导入组件时出错
注意:我确定导入地址是真的
mixin/logOut.ts 从'vue'导入Vue
import { Component } from 'nuxt-property-decorator'
import AppAlert from '~/components/Common/AppAlert'
@Component
export class LogOut extends Vue {
async LogOut() {
const confirm = await this.$dialog.show({
component: AppAlert,
props: {
title: { text: 'Exit ?', icon: 'exclamation-thick' },
body: 'Exit Connector ?',
btn: { text: 'Confirm', icon: 'power', color: 'error' }
}
})
if (confirm) {
this.$auth.logout()
}
}
}
错误文本是:
Cannot find module '~/components/Common/AppAlert' or its corresponding type declarations.ts(2307)
【问题讨论】:
-
如果你在这里写
AppAlert.ts会发生什么?因为我假设如果你不写扩展,它默认为.js。 -
AppAlert 是一个组件,它的扩展名是 .vue ,我添加了 .vue 但它没有修复
标签: typescript vue.js nuxt.js vue-property-decorator