[Vue]用户输入绑定之select(四)

select数据绑定

汽车品牌选择

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
  <title>hellovue</title>
</head>
<body>
<div id="myApp">
  <p>你最喜欢的汽车品牌是:{{mycar}}
    <select v-model="mycar">
    <option value="Lexus">Lexus</option>
    <option value="Mini">Mini</option>
    <option value="Benz">Benz</option>
    <option value="BMW">BMW</option>
  </select>
  </p>
</div>
<script>
  var myApp = new Vue({
    /*绑定标签的id*/
    el: '#myApp',
    /*标签上绑定的数据*/
    data: {
      mycar: 'Lexus'
    },
  })
</script>
</body>
</html>

END

posted @ 2020-03-05 11:32  LeoShi2020  阅读(467)  评论(0编辑  收藏  举报