Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt usage #20

Closed
mirabledictu opened this issue Aug 24, 2021 · 2 comments
Closed

Nuxt usage #20

mirabledictu opened this issue Aug 24, 2021 · 2 comments

Comments

@mirabledictu
Copy link

Hi, feel free to close this anytime.

Is there a best way of importing this in a Nuxt project?

First thing I did is to create a vue-global-api.ts file inside my plugins directory and import it in plugins in nuxt.config.ts. The types are working but when you run it, you'll still get undefined errors.

Second thing I did, which worked, is to just import vue-global-api in each of the layout component inside layouts folder.

Just wondering if there's a better way of doing this. Thanks!

@antfu
Copy link
Owner

antfu commented Aug 24, 2021

Consider using https://github.com/antfu/unplugin-auto-import which has first-class nuxt module built-in

@wobsoriano
Copy link

I tried unplugin-auto-import with nuxt

buildModules: [
  '@nuxt/typescript-build',
  '@nuxtjs/composition-api/module',
  'nuxt-typed-vuex',
  [
    'unplugin-auto-import/nuxt',
    {
      // global imports to register
      // imports: ['vue2']
      imports: [
        {
          '@nuxtjs/composition-api': CommonCompositionAPI,
        },
      ],
    },
  ],
],

Preset vue2 and custom preset still gives cannot find name 'defineComponent' etc..

Screen Shot 2021-08-24 at 6 12 21 PM

Also tried restarting vs code with no luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants