Home >Web Front-end >JS Tutorial >How to get the value in select in vue.js (detailed tutorial)

How to get the value in select in vue.js (detailed tutorial)

亚连
亚连Original
2018-06-02 10:17:318261browse

Now I will share with you an article about vue.js to get the value instance in select. It has a good reference value and I hope it will be helpful to everyone.

is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="./vue.js"></script>
</head>
<body>
<label id="app">
<select v-model="selected" >
 <option v-for="option in options" v-bind:value="option.value">
 {{ option.text }}
 </option>
</select>
<span>Selected: {{ selected }}</span>
</label>
<script>
new Vue({
 el: &#39;#app&#39;,
 data: {
 selected: &#39;A&#39;,
 options: [
  { text: &#39;One&#39;, value: &#39;A&#39; },
  { text: &#39;Two&#39;, value: &#39;B&#39; },
  { text: &#39;Three&#39;, value: &#39;C&#39; }
 ]
 }
})
</script>
</body>
</html>

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

About the method of closing the component by clicking outside the component in Vue (detailed tutorial)

Using Vue's routing permission management Questions about (detailed tutorial)

About the method of inserting variable parameters in vue.js tag attributes (detailed tutorial)

The above is the detailed content of How to get the value in select in vue.js (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn