D
D
devlocal2018-12-18 15:19:03
Vue.js
devlocal, 2018-12-18 15:19:03

How to build a form based on json metadata?

You need to create a component that will send a request to the server and receive the json structure of the future form.
How to create a component, connect and create a request to the server to get json is not a problem.
I can't figure out how to create a template out of N components based on the received data.
For example, if json contains information about what you need to show the input string Then, accordingly, you need to add a component with the input string to the template

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-12-18
@devlocal

Let the metadata be an array of objects containing two properties: the name of the component and an object with parameters:

formMeta: [
  { type: '...', props: { ... } },
  { type: '...', props: { ... } },
  ....
],

<div v-for="{ type, props } in formMeta" class="form-item">
  <component :is="type" v-bind="props"></component>
</div>

For example

N
nvdfxx, 2018-12-18
@nvdfxx

show what form json comes in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question