Heim  >  Fragen und Antworten  >  Hauptteil

NuxtJS: Problem beim Importieren von Komponenten in Mixin

Mein Stack ist Nuxtjs und Nuxt-property-decorator

Ich habe ein Mixin erstellt, um doppelte Methoden zu vermeiden

Diese Methode erfordert eine Komponente (Alarmkomponente)

Also habe ich die Komponente im Mixin importiert

AberBeim Importieren der Komponente ist ein Fehler aufgetreten

Hinweis: Ich bin sicher, dass die Importadresse echt ist

mixin/logOut.ts aus 'vue' Vue importieren

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()
    }
  }
}

Der Fehlertext lautet:

Cannot find module '~/components/Common/AppAlert' or its corresponding type declarations.ts(2307)

P粉267791326P粉267791326182 Tage vor327

Antworte allen(1)Ich werde antworten

  • P粉321676640

    P粉3216766402024-04-01 17:53:44

    我从此链接找到了答案。

    我添加了

    vue-shims.d.ts

    declare module "*.vue" {
      import Vue from 'vue'
      export default Vue
    }

    Antwort
    0
  • StornierenAntwort