Giter Site home page Giter Site logo

Comments (5)

pi0 avatar pi0 commented on September 28, 2024 2

@kissu Functionality of mentioned module is duplicate in the last version of nuxt/components, you can directly use <component :is="">. And other than integration with vue-lazy-hydration (#104) I do not recommend using it.

I think what this issue requires, is a way to check the existence of a component before using it. While we can make it sexier with a wrapper component like <NuxtComponent :name=""> or $components.has(), we can do this like this with Vue options api:

<component :is="componentId" v-if="$options.components[componentId]" />

Or from js:

import Vue from 'vue'

const componentExists = id => !!Vue.options.components[id]

Sandbox: https://codesandbox.io/s/immutable-wave-umwmz?file=/pages/index.vue:70-100

from components.

Rigo-m avatar Rigo-m commented on September 28, 2024 1

@vhoyer in vue3 you can use resolveComponent to check if a component exists. Nuxt/components is not needed in Nuxt3 since components gets auto-imported by the framework itself.

from components.

kissu avatar kissu commented on September 28, 2024

Did you tried this one? https://github.com/blokwise/dynamic#readme

from components.

Surt avatar Surt commented on September 28, 2024

The problem with that is that options.components only list the "loaded" ones. I can't see how to check if the component can be autoloaded before the :is to provide a "fallback" component in case the one I'm looking for does not exists (dinamic component name based on options)

from components.

vhoyer avatar vhoyer commented on September 28, 2024

What about this but using vue 3?

from components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.