简体   繁体   English

如何在值输入文本上显示选择选项的值? (vue.js 2)

[英]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/ 在此处查看完整代码: 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 , 您需要在demo div内移动输入,因为这是安装点,

and with v-model just use quotes <input type="text" v-model="selected"> 对于v-model只需使用引号<input type="text" v-model="selected">

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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