NuxtJS: Problem importing components in mixin
P粉267791326
P粉267791326 2024-03-31 20:49:22
0
1
388

My stack is Nuxtjs and Nuxt-property-decorator

I made a mixin to avoid duplicating methods

This method requires a component (alert component)

So, I imported the component in the mixin

ButI got an error when importing the component

Note: I am sure the import address is real

mixin/logOut.ts from 'vue' import 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()
    }
  }
}

The error text is:

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

P粉267791326
P粉267791326

reply all(1)
P粉321676640

I found the answer from this link.

I added

vue-shims.d.ts

declare module "*.vue" {
  import Vue from 'vue'
  export default Vue
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!