vue v-model结合select

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <p>{{ message }}</p>
      <select name="" v-model="fruit">
        <option value="苹果">苹果</option>
        <option value="桃">桃</option>
        <option value="香蕉">香蕉</option>
      </select>
      <p>{{ fruit }}</p>
    </div>

    <script>
      const app = new Vue({
        el: '#app',
        data: {
          message: 'Hello Vue.js!',
          fruit: '桃'
        },
      })
    </script>
  </body>
</html>

posted @ 2021-07-05 15:24  thomas_blog  阅读(260)  评论(0编辑  收藏  举报