No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to inject an element?

    Help
    2
    2
    2678
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      Zyme last edited by Zyme

      I have a component that I want to build a form.

      So I use it like <form-builder></form-builder> in my code.

      How would I inject components like <q-input> and <q-btn> to render depending on what data I pass to it?

      So my code would be something like:

      <template>
        <div>
          <form-builder data="data"></form-builder>
        </div>
      </template>
      
      ... stuff here ...
      
      data: {
        name: {
          type: 'input',
          label: 'Name'
        }.
        submit: {
          type: 'button',
          label: 'Submit'
        }
      }
      

      And from that it should convert the code to the elements:

      <q-input v-model="name" stack-label="Name" />
      <q-btn color="primary">Submit</q-btn>
      

      How do I do this?

      1 Reply Last reply Reply Quote 0
      • J
        jimmack1963 last edited by

        This is a vue.js feature called dynamic components:

        <template>
        <div class=“app-body row”>
        <template v-for="(child, index) in children">
        <component :is=“child” :key=“child.name”></component>
        </template>
        </div>
        </template>

        https://forum.vuejs.org/t/any-way-to-dynamically-add-multiple-vue-components-within-a-parent-vue-component/8209

        or

        https://coligo.io/dynamic-components-in-vuejs/

        1 Reply Last reply Reply Quote 0
        • First post
          Last post