question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for explicit import global components

See original GitHub issue

Can we use

<script setup lang="ts">
import { NuxtLink } from 'some-nuxt-lib-location'
</script>
<template>
  <div>
    <nuxt-link :to="`/test/123`">
      Random path
    </nuxt-link>
  </div>
</template>

Additional context

We use https://eslint.vuejs.org/rules/no-undef-components.html and all component should be registered locally.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
danielroecommented, Feb 25, 2022

What do you think @pi0 - would it be useful to expose a #components import for directly importing from scanned components?

3reactions
xiaoxiangmoecommented, Feb 24, 2022

Not a bug. It’s a feature request or question.

In vue-router, we can use import { RouterLink, RouterView } from 'vue-router'

<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'
</script>

<template>
  <header> 
    <div class="wrapper"> 
      <nav>
        <RouterLink to="/">Home</RouterLink>
        <RouterLink to="/about">About</RouterLink>
      </nav> 
  </header>
  <RouterView />
</template>

see

https://github.com/vuejs/create-vue-templates/blob/284fcf591115e5cf39e4461e2fd4cd2c5ea009bb/typescript-router/src/App.vue#L1-L2

Which lib should I import when I use <NuxtLink>?

Can I write import { NuxtLink } from 'nuxt3' or something else?

<script setup lang="ts">
import { NuxtLink } from 'nuxt3'
</script>

<template>
  <header> 
    <div class="wrapper"> 
      <nav>
        <NuxtLink to="/">Home</NuxtLink>
        <NuxtLink to="/about">About</NuxtLink>
      </nav> 
  </header> 
</template>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Component Registration - Vue.js
We can make components available globally in the current Vue application using the app.component() method: js import { createApp } from 'vue' const...
Read more >
Importing and Using Components in Nuxt 3 - Server Side Up
When migrating from Nuxt 2 to Nuxt 3, components are now imported and used through auto imports instead of explicit importing.
Read more >
don't register global components locally on referencing them
When registering as a global component, I do not want to import it. What happens instead? Direct path import and register to components...
Read more >
Is it a good practice to import shared sass variables into every ...
When we move components to a different project or repo, due to explicit imports for SCSS variables files, we don't have to worry...
Read more >
Advanced usage - Vuelidate
Using component mixin # ; { · } from '@vuelidate/core' import ; { ·, · } from '@vuelidate/validators' ; export default { setup...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found