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.

Dynamic component support

See original GitHub issue

Is this plugin support dynamic components? Such as using <component :is="" /> I tried to use this plugin using dynamic components, but it’s not rendering.

Example:

<!-- rendered to <mybutton /> -->
<component :is="'myButton'" />

<!-- correctly rendered -->
<myButton>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:29
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
Septiascommented, Jan 7, 2021

I would like it too

<template>
  <span>{{ node.title }}</span>
  <ul class="node_tree">
    <li v-for="child in node.children" :key="child.id" :class="child.breed">
      // it would be nice to select the appropriate component based on the child-type - which is a string
      <component :is="child.breed"></component>
      <Node v-if="child.breed == 'Folder'" :node="child"></Node>
      <a
        v-else-if="child.breed == 'DirectLink'"
        :href="'https://ilias.uni-freiburg.de/' + child.uri"
        >{{ child.title }}</a
      >
    </li>
  </ul>
</template>
13reactions
joniancommented, Sep 21, 2021

I’m using unplugin-auto-import for dynamic components. Does not support every use case but works for my needs. Maybe unplugin-vue-components can provide a resolver to use with unplugin-auto-import. You can see the complete repo here.

// vite.config.js

const DynamicComponentResolver = name => {
  const file = path.resolve(__dirname, `src/components/${name}.vue`)

  if (fs.existsSync(file)) {
    return file
  }
}

export default {
  plugins: [
    Vue(),
    Components(),
    Layouts(),
    Pages(),
    AutoImport({
      resolvers: [
        DynamicComponentResolver
      ]
    })
  ]
}
<!-- Button.vue -->

<template>
  <component :is="tag" />
</template>

<script>
export default {
  props: {
    rounded: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    tag() {
      return this.rounded ? RoundedButton : DefaultButton
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic component loader - Angular
This cookbook shows you how to add components dynamically. See the live example / download example of the code in this cookbook. Dynamic...
Read more >
Angular Dynamic Component With Service - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Loading Components Dynamically in an Angular App
A tutorial that shows how to create an Angular app with dynamic component loading.
Read more >
Dynamic Component supported functions - SketchUp Help
Following is a list of all functions supported within your dynamic components. Many of these functions are identical to functions found in spreadsheet ......
Read more >
Angular Dynamic Components: Building a Dialog System
In this tutorial, you will learn what dynamic components are and how they work in angular. ... Using a service to append the...
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