简体   繁体   中英

How to display the value of select option on value input text ? (vue.js 2)

My code is like this :

<div id="demo">
  <div>
    <select class="form-control" v-model="selected" required>
      <option v-for="option in options" v-bind:value="option.id">{{ option.name }}</option>
    </select>
    {{selected}}
  </div>
</div>

<input type="text" :name="elementName" v-model="{{selected}}">

See full code here : https://fiddle.jshell.net/stvct9er/1/

After select on combo box, I want to display value of select option on the input text

I try like above code. But it does not work

Please, help me to solve my problem

You need to move the input inside the demo div because this is the mounted point ,

and with v-model just use quotes <input type="text" v-model="selected">

https://fiddle.jshell.net/stvct9er/2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM