How to pass a component in Vue to variable?

Asked

Viewed 41 times

0

I have the following code:

<template>
<div>
    <h2><Info/></h2>
    <input type="text" maxlength="1" value=`<Info/>`/>
    <input type="text" maxlength="1" />
    <input type="text" maxlength="1" />
    <input type="text" maxlength="1" />
    <input type="text" maxlength="1" />
    <input type="text" maxlength="1" />
 </div>
</template>
<script>


import Info from "./Info.vue";

export default {
  name: "App",
  components: {Info}
}
</script>

I would like the value of to be passed to a variable, or even to the value of the direct input. But I don’t know how to do it, someone can help me?

  • What do you expect to be the textual representation of a Vue component?

  • It is only the value of an attribute, which is being sent in a <div>{{value}}</div>. In the template the only thing it returns to me is this value, so I’d like to put it within the value of the input.

1 answer

-2

Try to bind the value you need +- this way:

<input type="text" maxlength="1" :value="<Info/>" />

I’m not sure if it will work because I’m far from my laptop.

  • This way it doesn’t work

Browser other questions tagged

You are not signed in. Login or sign up in order to post.